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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|