Why is 'Type Mismatch' ??

Skerdi

Registered User.
Local time
Today, 07:47
Joined
Jun 27, 2007
Messages
47
Hi,
Can some1 tell me what syntax error I generate if I do this :

txtCustName = DLookup("Name", "tblCustomer", "Name like '" & "AB" & "*'" And "Address like '" & "GOLE" & "*'")

It says : Type Mismatch, why? Can I use two criterias in DLookup?

thnx in advance
Skerdi :)
 
1. You CERTAINLY can use two criteria in a domain aggregate function such as you are trying to do.

2. "Type Mismatch" means that your data type is not correct for one of the elements in the criteria expression.

I'm thinking that you have quotes imbalanced some sort of way and as a result something isn't in the form you need it to be.

Let's say that your apostrophe (or single-quote) will be called TICK and the shift of single-quote is double-quote, or DQ

You should be looking at DQ [Name] like TICK DQ & [AB] & DQ TICK and [Address] like TICK DQ & [GOLE] & DQ TICK DQ

3. Watch out for fields like [NAME] because NAME is a reserved word (I think). Use Access Help for "reserved words" to see words you should not use as field names.

4. Using the LIKE operator generally involves use of WILDCARDS unless the only ambiguity is upper/lower case issues. In which case the right-hand operand of LIKE should be all lower case. Use Access Help on the LIKE operator to see examples where you wildcard the search string.
 
Your syntax looks over complicated. Why not try

txtCustName = DLookup("Name", "tblCustomer", "Name like 'AB*' And Address like 'GOLE*'")

As Doc says it is never a good idea to use Name as a field name.
 
Thankyou The_Doc_Man
Thankyou Rabbie

Very helpful your replies. I did it :)

thanks again
bye
 

Users who are viewing this thread

Back
Top Bottom