DLookup doesn't work in 2007

AnnPhil

Registered User.
Local time
Today, 05:31
Joined
Dec 18, 2001
Messages
246
I have several DLookups in my 2003 version that work fine, but when i upgrade the db to 2007 they do not work. Is the syntex different in 2007?

Here is just an example of one of them used in a form.

=DLookUp("[Name]","[FMLA_Yearly List]","[FMLA_ID]=[Forms]![FMLA Log]![FMLA_ID]")

I search other threads and i get a couple different syntex, but none of them work.

Thanks in advance for any help
 
I tried looking at that link before and still got error message says invalid syntax. This time i cut and pasted the names into the example and still no go :confused:

DLookup("Name ", " FMLA_Yearly List ", " FMLA_ID = " & forms! FMLA Log! FMLA_ID)
 
If that's a direct cut/paste, there are spaces in there that are either in error or need to be bracketed. What are the exact names, and what is the data type of FMLA_ID?
 
"Name" is a text field, "FMLA_Yearly List" is a query, "FMLA_ID" is a number field

I tried taking out the spaces where i thought they should be taken out and still no go.

=DLookup("Name", "FMLA_Yearly List", "FMLA_ID = " & forms! FMLA Log! FMLA_ID)
 
Name is an Access Reserved Word and needs to be in square brackets (and in reality it should not be used as a field or object name at all).
 
And you still have spaces in there. Try

=DLookup("Name", "FMLA_Yearly List", "FMLA_ID = " & forms!FMLA Log!FMLA_ID)
 
And you still have spaces in there. Try

=DLookup("Name", "FMLA_Yearly List", "FMLA_ID = " & forms!FMLA Log!FMLA_ID)

And better still this:

=DLookup("[Name]", "FMLA_Yearly List", "FMLA_ID = " & forms!FMLA Log!FMLA_ID)
 
Thanks SO MUCH everyone, i finally got it to work! I took both your advise and had to add more brackets in order for it to work

Here is what worked

=DLookUp("[Name]","[FMLA_Yearly List]","[FMLA_ID] = " & [Forms]![FMLA Log]![FMLA_ID])

Which is what i had in 2003 but with the criteria area written differently, now i hope it works on the other two i have yet to change :)
 
And better still this:

=DLookup("[Name]", "FMLA_Yearly List", "FMLA_ID = " & forms!FMLA Log!FMLA_ID)

I agree that Name is a reserved word that shouldn't be used, but I don't think it caused a problem here. A brief test resulted in no error in a test db:

?dlookup("name","table1","searchtext = 'blah'")
paul
 
And we've had posters here before who have used it and when the brackets were added it worked just fine. But the main lesson is to NOT use NAME as an object or field name.
 
Lesson learned. They say the lessons learned the hard way are the ones you remember most often. Thanks again !!!!
 
Actually, I prefer the Ambrose Bierce definition of experience.

Experience is that which allows us to recognize our mistakes when we make them again.
 

Users who are viewing this thread

Back
Top Bottom