A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

IS this DLOOKUP possible within a query?



 
 
Thread Tools Display Modes
  #1  
Old June 26th, 2008, 08:34 AM posted to microsoft.public.access.queries
Stu
external usenet poster
 
Posts: 15
Default IS this DLOOKUP possible within a query?

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
  #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


  #3  
Old June 26th, 2008, 09:27 AM posted to microsoft.public.access.queries
Stu
external usenet poster
 
Posts: 15
Default IS this DLOOKUP possible within a query?

On 26 Jun, 08:48, "Allen Browne" wrote:
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- Hide quoted text -


- Show quoted text -


Sorry, me being stupid :-)

This is what I should be using and still can't get it to work.

DLookUp("WkInd","tblWeekNum","WkYr" =
(Format([AK_DELIV_DATE],"wwyy")))
  #4  
Old June 26th, 2008, 10:24 AM posted to microsoft.public.access.queries
Allen Browne
external usenet poster
 
Posts: 11,706
Default IS this DLOOKUP possible within a query?

Put the = inside the quotes, and concatenate with &.

Look at the link in the previous reply if you are still stuck.

--
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
...
Sorry, me being stupid :-)

This is what I should be using and still can't get it to work.

DLookUp("WkInd","tblWeekNum","WkYr" =
(Format([AK_DELIV_DATE],"wwyy")))
  #5  
Old June 26th, 2008, 10:34 AM posted to microsoft.public.access.queries
Stu
external usenet poster
 
Posts: 15
Default IS this DLOOKUP possible within a query?

On 26 Jun, 10:24, "Allen Browne" wrote:
Put the = inside the quotes, and concatenate with &.

Look at the link in the previous reply if you are still stuck.

--
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

...
Sorry, me being stupid :-)

This is what I should be using and *still can't get it to work.

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


Thanks Allen - got it now.
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:55 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.