PC Review


Reply
Thread Tools Rate Thread

Query Expression using DLookUp

 
 
Wei
Guest
Posts: n/a
 
      7th Jan 2004
The following expression returns "#Error", can anyone
please tell me why?

CL: IIf([VEH_YEAR]=2003,DLookUp("[2003CL]","vrg-
mce","[Vehicle_Code]=" & [VEH_CODE]),"do something else")

"vrg-mce" is a table that contains fields like
Vehicle_Code, 2003CL, etc.

I think the problem is in here:"[Vehicle_Code]=" &
[VEH_CODE]. But I don't know how to fix it.

Thanks for any help.

Wei
 
Reply With Quote
 
 
 
 
Allen Browne
Guest
Posts: n/a
 
      7th Jan 2004
If VEH_CODE is a Text type field, try:

CL: IIf([VEH_YEAR] = 2003,
DLookUp("[2003CL]","vrg-mce","[Vehicle_Code] = """ & [VEH_CODE] & """"),
"do something else")


If it is a Number type field, you need to consider the case where VEH_CODE
is Null, and therefore the 3rd argument would equate to just:
[Vehicle_Code] =

To prevent that:

CL: IIf([VEH_YEAR] = 2003,
DLookUp("[2003CL]","vrg-mce","[Vehicle_Code] = " Nz([VEH_CODE], 0)),
"do something else")

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

"Wei" <(E-Mail Removed)> wrote in message
news:0ab701c3d530$3af3ab60$(E-Mail Removed)...
> The following expression returns "#Error", can anyone
> please tell me why?
>
> CL: IIf([VEH_YEAR]=2003,DLookUp("[2003CL]","vrg-
> mce","[Vehicle_Code]=" & [VEH_CODE]),"do something else")
>
> "vrg-mce" is a table that contains fields like
> Vehicle_Code, 2003CL, etc.
>
> I think the problem is in here:"[Vehicle_Code]=" &
> [VEH_CODE]. But I don't know how to fix it.
>
> Thanks for any help.
>
> Wei



 
Reply With Quote
 
 
 
 
Michel Walsh
Guest
Posts: n/a
 
      7th Jan 2004
Hi,


The table name is illegal as a table name. You may try to use [ ] around
it:

"[vgr-mce]"


(second argument of your DLookup).



If the vehicle code is some text, you may try:

"Vehicle_Code=""" & VEH_CODE & """"
1 3 4


as third argument. The numbers under the line are not part of the code, they
just show the number of involved double-quote.



Hoping it may help,
Vanderghast, Access MVP


"Wei" <(E-Mail Removed)> wrote in message
news:0ab701c3d530$3af3ab60$(E-Mail Removed)...
> The following expression returns "#Error", can anyone
> please tell me why?
>
> CL: IIf([VEH_YEAR]=2003,DLookUp("[2003CL]","vrg-
> mce","[Vehicle_Code]=" & [VEH_CODE]),"do something else")
>
> "vrg-mce" is a table that contains fields like
> Vehicle_Code, 2003CL, etc.
>
> I think the problem is in here:"[Vehicle_Code]=" &
> [VEH_CODE]. But I don't know how to fix it.
>
> Thanks for any help.
>
> Wei



 
Reply With Quote
 
Wei
Guest
Posts: n/a
 
      7th Jan 2004
Yes, thank you so much, Vanderghast! It worked!

But why do I need to put so many quotation marks? Thanks a
lot if you could explain it to me, so that I don't make
the same mistake again.

Wei
>-----Original Message-----
>Hi,
>
>
>The table name is illegal as a table name. You may try to

use [ ] around
>it:
>
> "[vgr-mce]"
>
>
>(second argument of your DLookup).
>
>
>
>If the vehicle code is some text, you may try:
>
>"Vehicle_Code=""" & VEH_CODE & """"
>1 3 4
>
>
>as third argument. The numbers under the line are not

part of the code, they
>just show the number of involved double-quote.
>
>
>
>Hoping it may help,
>Vanderghast, Access MVP
>
>
>"Wei" <(E-Mail Removed)> wrote in

message
>news:0ab701c3d530$3af3ab60$(E-Mail Removed)...
>> The following expression returns "#Error", can anyone
>> please tell me why?
>>
>> CL: IIf([VEH_YEAR]=2003,DLookUp("[2003CL]","vrg-
>> mce","[Vehicle_Code]=" & [VEH_CODE]),"do something

else")
>>
>> "vrg-mce" is a table that contains fields like
>> Vehicle_Code, 2003CL, etc.
>>
>> I think the problem is in here:"[Vehicle_Code]=" &
>> [VEH_CODE]. But I don't know how to fix it.
>>
>> Thanks for any help.
>>
>> Wei

>
>
>.
>

 
Reply With Quote
 
Wei
Guest
Posts: n/a
 
      7th Jan 2004
Thanks Allen!

Wei


>-----Original Message-----
>If VEH_CODE is a Text type field, try:
>
>CL: IIf([VEH_YEAR] = 2003,
>DLookUp("[2003CL]","vrg-mce","[Vehicle_Code] = """ &

[VEH_CODE] & """"),
>"do something else")
>
>
>If it is a Number type field, you need to consider the

case where VEH_CODE
>is Null, and therefore the 3rd argument would equate to

just:
> [Vehicle_Code] =
>
>To prevent that:
>
>CL: IIf([VEH_YEAR] = 2003,
>DLookUp("[2003CL]","vrg-mce","[Vehicle_Code] = " Nz

([VEH_CODE], 0)),
>"do something else")
>
>--
>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.
>
>"Wei" <(E-Mail Removed)> wrote in

message
>news:0ab701c3d530$3af3ab60$(E-Mail Removed)...
>> The following expression returns "#Error", can anyone
>> please tell me why?
>>
>> CL: IIf([VEH_YEAR]=2003,DLookUp("[2003CL]","vrg-
>> mce","[Vehicle_Code]=" & [VEH_CODE]),"do something

else")
>>
>> "vrg-mce" is a table that contains fields like
>> Vehicle_Code, 2003CL, etc.
>>
>> I think the problem is in here:"[Vehicle_Code]=" &
>> [VEH_CODE]. But I don't know how to fix it.
>>
>> Thanks for any help.
>>
>> Wei

>
>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
dlookup using a date defiined by another dlookup =?Utf-8?B?QmVubnlESGlsbA==?= Microsoft Access VBA Modules 1 8th Aug 2007 01:56 AM
Dlookup Using Expression Builder =?Utf-8?B?d2lsYnVyMTM=?= Microsoft Access Queries 4 30th Jul 2007 10:10 PM
Dlookup Update Query Expression Builder =?Utf-8?B?c2NyYXRjaHRyYXg=?= Microsoft Access 8 4th Apr 2006 08:30 PM
Dlookup Query Expression =?Utf-8?B?UGF1bC4=?= Microsoft Access 1 29th Jun 2005 08:19 PM
Dlookup or not dlookup Bruce Ritchie Microsoft Access 2 7th Nov 2003 01:50 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:48 AM.