Is _ an issue with VBA?

Zaeed

Registered Annoyance
Local time
Today, 14:48
Joined
Dec 12, 2007
Messages
383
Hi, I have some code that runs through and pulls out a value from a table based on the following code

Code:
SELECT tbl_Users.UserId FROM tbl_Users INNER JOIN tbl_Secondary_Location ON tbl_Users.Department = tbl_Secondary_Location.LocationID WHERE ((tbl_Secondary_Location.Quality_&_Food_Safety = -1) AND (tbl_Users.Role = 'Manager'));

I am however getting a bug on the WHERE clause, and I beleive that its due to the use of _ in the Quality_&_Food_Safety. Is this the cause?
And if so, is there a way around it? :confused:
 
Actually I would say it's the '&' that's the problem.

Generally, I would avoid using any non-alphanumeric characters. (To be fair, there is nothing wrong with underscore, but I just prefer to avoid it entirely, using CamelCase instead.)
 
I agree with the yellow dude. You'll have to bracket the field name.
 
ahhhhh brackets... you just saved me from a mild mental breakdown there pbaldy.. i was worried i had to rewrite a whole heap of code...

thanks
 
No problem Matt. Like Banana, I prefer CamelCase, but I've developed a couple of apps with another guy who loves underscores, so I know they don't cause a problem in the query.
 

Users who are viewing this thread

Back
Top Bottom