VBA oddity

  • Thread starter Thread starter BruceM
  • Start date Start date
B

BruceM

I had been having a great deal of difficulty attempting to define a string
to be used in a filter. I was trying to use an unbound form to apply
filtering to a report's recordset. In the course of doing that I defined
strComp as String, but was having problems with it expecting a "(" (without
the quotes). Finally I tried:

Dim strComp as String
strComp = "Test Message"
msgBox strComp

Same result. It wanted a (. However, when I changed strComp to strCom or
strCompl, no problem. Does anybody know what I stumbled upon, and are there
any more like it?
 
StrComp is a VBA function that allows you to compare text strings for match.
That is why you cannot use it as a variable name.

See this MS Office article for information about lists of VBA functions,
etc.:
http://office.microsoft.com/en-us/assistance/HP011361681033.aspx

See these Knowledge Base articles for more information about reserved words
and characters that should not be used:

List of reserved words in Access 2002 and Access 2003
http://support.microsoft.com/default.aspx?scid=kb;en-us;286335

List of Microsoft Jet 4.0 reserved words
http://support.microsoft.com/?id=321266

Special characters that you must avoid when you work with Access
databases
http://support.microsoft.com/?id=826763
 
Thanks for the explanation and the links. I already had the second link
bookmarked, but not the first, which is more comprehensive. I didn't have
the third link either. I should have recognized that it was asking for a
parentheses because strComp is a function.
 
Back
Top