Help with DLOOKUP (1 Viewer)

TasCat09

New member
Local time
Tomorrow, 02:16
Joined
Aug 7, 2016
Messages
10
Hello

Can somebody help me understand why the top line of code works OK but the second doesn't?

recID = DLookup("[ID]", "RECIPES", "RecipeName = 'chow mein'")

recID = DLookup("[ID]", "RECIPES", "RecipeName = '" & Me.txtRecipe & "')"

Where txtRecipe is a text box on the current form that's value is 'chow mein'
 

stopher

AWF VIP
Local time
Today, 17:16
Joined
Feb 1, 2006
Messages
2,395
Try:
recID = DLookup("[ID]", "RECIPES", "RecipeName = '" & Me.txtRecipe & "'")
 

TasCat09

New member
Local time
Tomorrow, 02:16
Joined
Aug 7, 2016
Messages
10
Thanks Stopher

That worked like a charm. I also had success with the following:

recID = DLookup("[ID]", "RECIPES", "RecipeName = '" & Me.txtRecipe & "'")
 

Users who are viewing this thread

Top Bottom