Dlookup not working in Subform

Keiath

Registered User.
Local time
Today, 13:14
Joined
Jan 6, 2012
Messages
104
Hi Guys

I have a subform that has the Expense Code from the Expense Codes Table and I want to look up the Description (yes I know its not correctly spelled in the formula but it is in the table)

=DLookUp("Expense Discription","Expense Codes","Expense Code=" & [ExpCombo])

But I keep getting "error" returned

Ihave double checked spelling field names ect

Any ideas?

Keiath
 
Try this,
Code:
=DLookUp("[COLOR=Red][B][[/B][/COLOR]Expense Discription[COLOR=Red][B]][/B][/COLOR]","[COLOR=Red][B][[/B][/COLOR]Expense Codes[COLOR=Red][B]][/B][/COLOR]","[COLOR=Red][B][[/B][/COLOR]Expense Code[COLOR=Red][B]][/B][/COLOR] = " & [ExpCombo])
Are you sure if the ExpCombo returns a Number if it returns a String then enclose them between single quotes.
Code:
=DLookUp("[COLOR=Red][B][[/B][/COLOR]Expense Discription[COLOR=Red][B]][/B][/COLOR]","[COLOR=Red][B][[/B][/COLOR]Expense Codes[COLOR=Red][B]][/B][/COLOR]","[COLOR=Red][B][[/B][/COLOR]Expense Code[COLOR=Red][B]][/B][/COLOR] = '" & [ExpCombo] & "'")
Also, to make life simple, why not use JOIN for the Form's record source and get the description field instead of using DLookup, which might be a bit heavy.
 
=DLookUp("[Expense Discription]","[Expense Codes]","[Expense Code] = " & [ExpCombo])

This worked is this because its 2010 I am working with?

And Thank you So much
 
This worked is this because its 2010 I am working with?
No, because you had spaces in your field name, if you have special characters (yes that includes space) you need to enclose them in Square brackets.
And Thank you So much
No problem ! But please, for the love of all humanity, please do not double post ! It wastes people's time and effort.
I use 2 sites as a ref point, this site gave me the correct answer (thank you again) so i posted the solution onto the other site, so a) they know not to bother answering and b) that others can see the answer
If you are doing this, please inform the other readers, so that we will see if we really need to work on this or not !
 
I will refrain from double posting and thanks for the tip on the space requiring enclosing
 

Users who are viewing this thread

Back
Top Bottom