It's not a date, it's a string!

mafhobb

Registered User.
Local time
Today, 17:46
Joined
Feb 28, 2006
Messages
1,249
I may have made a mistake with this...

I have a table called tblSKUMessage with two fields: [SKU#] and [SKUMessage]

I am now trying to retrieve the SKUMessage with this code:

Code:
Dim SKU as String

SKU = "FUTK6900"
    
'Bring the Notes on the SKU from the SKU Message table
        Me.txtSKUNotes = Nz(DLookup("SKUMessage", "tblSKUMessage", "SKU#= '" & SKU & "'"), "No Message for this SKU.")

When I run this I get error 3075: Syntax error in date expression 'SKU#='FUTK6900".

My guess is that it thinks that the variable to look for is a date becasue of the # symbol. I will not use special characters like this for variable names in the future but for now, how can I get around this problem?

Thanks

mafhobb
 
I've not tried with the hash character but using CHR(34) in place of " can save some heartache. So perhaps;
Code:
Dim SKU as String

SKU = "FUTK6900"
    
'Bring the Notes on the SKU from the SKU Message table
        Me.txtSKUNotes = Nz(DLookup("SKUMessage", "tblSKUMessage", "SKU[COLOR="Red"]" & CHR(35) & "[/COLOR]= '" & SKU & "'"), "No Message for this SKU.")
might do the trick.
 
Nope...It returned the same error :(
 
Simply put squarebrackets around "[SKU#]='" .....

JR
 
I have to confess that when I read your comment I thought "It can't be that easy..."...but...it is! I can't believe that I did not think of that!

Thanks

mafhobb
 
Simply put squarebrackets around "[SKU#]='" .....

JR

aniunder.gif
 
for this sort of reason, i would not put "characters" like # in a field name.
 

Users who are viewing this thread

Back
Top Bottom