DLookup with Multiple key field criteria in same file
- From: nopolla <nopolla@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 13 Apr 2009 08:28:01 -0700
This is my first question and I would really appreciate anyones help.
I am new to Access 2003. I am attempting to validate a field in a form using
DLookup.
I have:
Private Sub Plan_Exit(Cancel As Integer)
Dim B As String
Dim strWhere As String
strWhere = "(Company = " & Me.Company & ") And (Plan = ""& Me.Plan "")"
B = Nz(DLookup("[gmgplc]", "[grpmst]", strWhere), "zzzz")
MsgBox Company
MsgBox Me.Company
MsgBox Me.Plan
MsgBox Plan
MsgBox B
If B = "zzzz" Then
MsgBox "Invalid Plan"
[Plan] = " "
[Plan].Undo
End If
End Sub
All the MsgBox fields reflect the correct values when I run it, but I keep
getting the "zzzz" s even when both company and Plan values match.
Both are indexed fields with duplicates allowed.
I am thinking it must be how I am structuring the B = line.
Thanks in advance
--
nopolla
.
- Follow-Ups:
- Re: DLookup with Multiple key field criteria in same file
- From: Chegu Tom
- Re: DLookup with Multiple key field criteria in same file
- From: John W . Vinson
- Re: DLookup with Multiple key field criteria in same file
- Prev by Date: Re: Hiding new record row
- Next by Date: linking scanned field slips to forms
- Previous by thread: Hiding new record row
- Next by thread: Re: DLookup with Multiple key field criteria in same file
- Index(es):
Relevant Pages
|