DLookup with Multiple key field criteria in same file



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
.



Relevant Pages