You
always need to use this " & variable & " syntax. This is because you want to embed the
value of the variable into the SQL statement. If you don't use this syntax, you will be embedding the
name of the variable instead.
Using your SQL statement as an example, suppose you have:
EIN = 1
selectedGroup = 2
then if you do:
"INSERT INTO linkToCategory(ein, categoryId) " & _
"VALUES (" & EIN & ", " & selectedGroup &")"
that gives you this SQL statement:
Code:
INSERT INTO linkToCategory(ein, categoryId) VALUES (1, 2)
which is what you want.
If you don't use the " & variable & " syntax then you have:
"INSERT INTO linkToCategory(ein, categoryId) " & _
"VALUES (EIN, selectedGroup)"
which gives this SQL statement:
Code:
INSERT INTO linkToCategory(ein, categoryId) VALUES (EIN, selectedGroup)
and you don't want that because the database will assume that EIN and selectedGroup are the actual values you're trying to insert. The database will not know that EIN and selectedGroup are variables in your code that contain the values you want to insert.
hth
Phil