View Full Version : Brain Dead


Davef28
06-18-2002, 02:34 AM
I have following code (PREVIOUS POST WAS INCORRECT)

strOrder = "[Customer Name] = '" & [Forms]![Customer Add]![Customer Name] & "'" & " " & "AND" & " " & "[Customer Day] = '" & [Forms]![Customer Add]![DayPass] & "'"

[Forms]![Customer Add]![Customer Name] can have an apostrophe in it which causes a problem with syntax. I know this is probably really easy but my brain seems to not function this morning. What other delimeter can I use ie you use # for time ?

thanks

Fizzio
06-18-2002, 02:40 AM
Try using double quotes rather than single ie.

strOrder = "[Customer Name] = """ & [Forms]![Customer Add]![Customer Name] & """ & " AND [Customer Day] = '" & [Forms]![Customer Add]![DayPass] & '"

HTH

Davef28
06-18-2002, 02:56 AM
No luck I am afraid.

Fizzio
06-18-2002, 03:01 AM
The syntax may not be correct but the principle is. I have not got access to MS Access at the minute so I cannot test it out. Are you using the string to filter something? You may consider using the customer ID (via a DLookup) to filter rather than the name as it potentially could be duplicated.

Davef28
06-18-2002, 03:07 AM
Yes, I realise the principle is. It must be just a case of getting the correct number of " or ' . I cannot do a DLookup because the Customer Name will be duplicated, the other fields won't.

I will keep trying, thanks.

cogent1
06-18-2002, 04:02 AM
OK try this ;


strOrder = "[Customer Name] = """ & [Forms]![Customer Add]![Customer Name] & """" & " AND " & "[Customer Day] = '" & [Forms]![Customer Add]![DayPass] & "'"


That worked for me. You have redundant quotes in your SQL, you can just pad the AND with spaces

Davef28
06-18-2002, 04:26 AM
Thanks, works for me.