View Single Post
  #2  
Old June 26th, 2008, 08:48 AM posted to microsoft.public.access.queries
Allen Browne
external usenet poster
 
Posts: 11,706
Default IS this DLOOKUP possible within a query?

The 3rd argument for DLookup() is the criteria.
You need to use an expression such as:
SomeField = SomeValue
e.g.:
"[Field99] = 999"

As it is, the expression:
(Format([AK_DELIV_DATE],"wwyy"))
will evalutate to something like:
2608
That text can be treated as a non-zero value, so Access treats the criterion
as True. (Zero is False.) Since it is True for any record, the first record
it tries matches, and hence you get the first one returned.

For help with forming the 3rd argument, see:
Getting a value from a table: DLookup()
at:
http://allenbrowne.com/casu-07.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Stu" wrote in message
...
I want to create the lookup criteria from a date field withn the query
itself but can't get it to work. The lookup I'm using always returns
1 (when it should be 908,1008 etc)

DLookUp("WkInd","tblWeekNum",(Format([AK_DELIV_DATE],"wwyy")))

Is it possible to do the lookup this way and, if so, can you please
tell me where Im going wrong.

TIA