Help with DLOOKUP (1 Viewer)

TasCat09

New member
Local time
Today, 21:12
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, 12:12
Joined
Feb 1, 2006
Messages
2,396
Try:
recID = DLookup("[ID]", "RECIPES", "RecipeName = '" & Me.txtRecipe & "'")
 

TasCat09

New member
Local time
Today, 21:12
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