~
Syntax for @ and & in VBA criteria string
In an Access97 query, the following criteria works perfectly on a text field containing email addresses:
Like "*" & "@aol.com"
However, I cannot seem to get the syntax correct to use that criteria in my VBA string variable.
Dim strLike as String
strLike = "Like "*" & "@aol.com""
' I've tried all sorts of combinations of syntax with "" and &&.
The Microsoft Access compile errors include:
Expected: end of statement
Invalid character 'indicating the @
When I don't get a compile error, I get a runtime error:
3075 : Syntax error (missing operator) in query expression '(((tablename.fieldname) Like * & aol.com))'
I've tried different quotation syntax, still get the errors. A double ampersand is supposed to allow one ampersand to be used in a string, but that gives the errors as well. I am baffled that the @ is an invalid character.
I have tried searching Access help, Microsoft Knowledgebase, Tek-Tips forums without seeing the resolution. Thanks in advance for any help at the end of this frustrating week.
~ db ~
~*~*~*~*~*~
Show me the way home.
~*~*~*~*~*~
Syntax for @ and & in VBA criteria string
In an Access97 query, the following criteria works perfectly on a text field containing email addresses:
Like "*" & "@aol.com"
However, I cannot seem to get the syntax correct to use that criteria in my VBA string variable.
Dim strLike as String
strLike = "Like "*" & "@aol.com""
' I've tried all sorts of combinations of syntax with "" and &&.
The Microsoft Access compile errors include:
Expected: end of statement
Invalid character 'indicating the @
When I don't get a compile error, I get a runtime error:
3075 : Syntax error (missing operator) in query expression '(((tablename.fieldname) Like * & aol.com))'
I've tried different quotation syntax, still get the errors. A double ampersand is supposed to allow one ampersand to be used in a string, but that gives the errors as well. I am baffled that the @ is an invalid character.
I have tried searching Access help, Microsoft Knowledgebase, Tek-Tips forums without seeing the resolution. Thanks in advance for any help at the end of this frustrating week.
~ db ~
~*~*~*~*~*~
Show me the way home.
~*~*~*~*~*~