Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dlookup Type Mismatch problem

Status
Not open for further replies.

nq

IS-IT--Management
Apr 1, 2002
102
AU
I am using a Dlookup function to find a record. There are two parameters to pass to the function, one is text (varOld) and the other is numeric (varYear).

Debug.Print varOld
Debug.Print varYear
varTeacher = DLookup("[Super]", "tblPlacements", "Super='" & varOld & "'" And "Year=" & varYear)

The two debug statements confirm that the correct data is being passed. However, the function always returns a "Type Mismatch" error on the Dlookup line.

I have split the Dlookup function into two and both work individually:

varTeacher = DLookup("[Super]", "tblPlacements", "Super='" & varOld & "'"

varTeacher = DLookup("[Super]", "tblPlacements", "Year=" & varYear)

Whenever I use Dlookup with the AND conjunction, the type mismatch error occurs.

Nigel.

 
How are ya nq . . .

. . . and this:
Code:
[blue]DLookup("[Super]", "tblPlacements", "Super='" & varOld & [purple][b]"' And Year = "[/b][/purple] & varYear)[/blue]

Calvin.gif
See Ya! . . . . . .
 
It works. Thanks.
I keep falling into this trap - there must be a set of syntax rules somewhere that I can learn from.

Nigel.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top