Solved dLOOKUP

sbaud2003

Member
Local time
Today, 05:01
Joined
Apr 5, 2020
Messages
186
Me.TXTUC.value = DLookup([Unit Code], "UNIT", "[unitid] = '" & CMP001 & "'")
I am using the above codes to get the [Unit Code] where unitid is a string character "CMP001" but flases error
 
If that is a value and not a variable? then just hard code it.?
 
I couldn't see the error message and number from here.... :unsure:
But I'll take a guess - you have no quotes around your field name.
"[Unit Code]"
 
Hi. I think you also need to put the field name in quotes.

Edit: Ugh, too slow...
 
Put together:

Me.TXTUC = DLookup("[Unit Code]", "UNIT", "[unitid] = 'CMP001'")

If you want unitid parameter to be dynamic, reference control that contains value:

Me.TXTUC = DLookup("[Unit Code], "UNIT", "[unitid] = '" & Me.tbxUID & "'")

Why do you need to save Unit Code if you have UnitID in record? Retrieve Unit Code in query joining tables.

Advise not to use spaces in naming convention.
 
Thank you very Much... Now I got it
This forum is wonderful...
Have a safe day
 

Users who are viewing this thread

Back
Top Bottom