Help with DLookup Field

G

Guest

I worked on a project at home, using Access 2003. I used the following
function in a textbox on one of my forms:
=DLookUp("[Next]",Enforcement Table Query","[CodeID]=[Enforcement Table
Query]!Code")
This looked up prior enforcement numbers, and then gave the user an option
to assign the "Next" one as a new one.
I then brought my query back to the office, which is in the dark ages of
Access 1997. I didn't think there would be any effect for something this
simple. But I did change the name of some of my queries and fields. The
text box that I amended has the following code:
=DLookUp("[Next]","Enforcement Log Counting Query","
Code:
 = [Enforcement
Log Counting Query]!Code")
This one now has the same number, which happens to be the number of the
first record in the query, and never changes.  So I tried typing one by
scratch, several different ways:
=DLookUp("[Next]","Enforcement Log Counting
Query","forms![Me]!Code=[Enforcement Log Counting Query]!Code")
or
=DLookUp("[Next]","Enforcement Log Counting Query","[Code]=[Enforcement Log
Counting Query]!Code")
or
=DLookUp("[Next]","Enforcement Log Counting Query","Code=[Enforcement Log
Counting Query]!Code")
or
=DLookUp("[Next]","Enforcement Log Counting Query","[Code]=[Enforcement Log
Counting Query]![Code]")
I have played with brackets and quotation marks, and always either get a
blank field or a "#Error" message.
Any suggestions would be greatly appreciated.
 
G

Guest

Have you tried:

=DLookUp("[Next]","Enforcement Log Counting Query","
Code:
=" & [Enforcement
Log
Counting Query]![Code])

Your coding is looking for a value for 'Code' = to the string "Enforcement
Log  Counting Query]!Code" (i.e. the actual words contained within the "'s) ,
rather than the value returned by "Enforcement Log > Counting Query]!Code".

Good luck.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top