Trouble with SQL: ERROR 3075

G

Glen

The following code is presenting a problem for me and I don't know
enough about SQL to correct it quickly. Any help would be appreciated.

I am trying to take the field values of a certain record and place
them into a temporary table. I need this to be done when the table ID
equals the current record in the form. The error is:" syntax error
(comma) in query expression "

strSQL = "SELECT
([SClss],[SHll],[VsNm],[FirstAvailDate],"
strSQL = strSQL & "[LastAvailDate],[AvailType],[UIC]) INTO tblSSHEADER
FROM User_Data "
strSQL = strSQL & "WHERE [ID] = & Me![SSelect]"
DoCmd.RunSQL (strSQL)
 
T

tminihan

Depending on whether your ID is a string or a numeric:
you will need to use ' for string
and " for numeric.

strSQL & "WHERE [ID] = '" & Me![SSelect]"'"
str SQL & "WHERE [ID] = " & Me![SSelect]"
 
G

Glen

Thank you both for your help. You are right tmini, I had a numeric
value that required the double quotes. I did it like this though and
it seems to work okay, " & Me.[SSelect] & ". I never did remove the
parentheses from around the field list but it still works just fine.
They must not be necessary in SQL for this operation. I have a hard
time keeping it straight between the different languages. Anyway,
thanks again.
 
W

warrior

You're welcome.

Just a little tip. Access doesn't require brackets unless you have a
space between the field name.

Example: Me Total would be [MeTotal]
MeTotal would be MeTotal

I put them in every time just to be sure. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top