syntax error

G

Guest

I''m getting a syntax error on the following line:

DoCmd.RunSQL "UPDATE[Table1] set[InUse] = '" & str9 & "' WHERE [Stock Num]
= '" & str1 & "'"

The error message is saying:
Syntax Error (missing operator) in query expression '[StockNum] = "ABC'"

Any help in determing what is wrong would be appreciated. Thanks for the
help....
 
D

Douglas J Steele

It could be because you don't have a space between the keyword Set and the
field name [InUse]
 
G

Guest

I inserted a space and got the same error. Here is how I set the variable
called str1.

If IsNumeric(TmpUnit) = True Then
str1 = Me.Rental_Field
Else
str1 = "'" & Me.Rental_Field & "'"
End If

Can this be causing my error? TmpUnit can be all numeric, all alpha, or a
combination of mixed characters. Is there a better way to handle this?
Thanks again for all of the help..........

--
JT


Douglas J Steele said:
It could be because you don't have a space between the keyword Set and the
field name [InUse]

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


JT said:
I''m getting a syntax error on the following line:

DoCmd.RunSQL "UPDATE[Table1] set[InUse] = '" & str9 & "' WHERE [Stock Num]
= '" & str1 & "'"

The error message is saying:
Syntax Error (missing operator) in query expression '[StockNum] = "ABC'"

Any help in determing what is wrong would be appreciated. Thanks for the
help....
 
D

Douglas J Steele

Yes, that's the culprit

Whether or not your value is numeric isn't relevant: all that matters is the
data type of your database field. If it's a Text field, you must have quotes
around the value, whatever it is. Since you're using '" and "' in building
your SQL, you've taken care of that. What you're ending up with is 2 single
quotes in a row, which is not required.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


JT said:
I inserted a space and got the same error. Here is how I set the variable
called str1.

If IsNumeric(TmpUnit) = True Then
str1 = Me.Rental_Field
Else
str1 = "'" & Me.Rental_Field & "'"
End If

Can this be causing my error? TmpUnit can be all numeric, all alpha, or a
combination of mixed characters. Is there a better way to handle this?
Thanks again for all of the help..........

--
JT


Douglas J Steele said:
It could be because you don't have a space between the keyword Set and the
field name [InUse]

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


JT said:
I''m getting a syntax error on the following line:

DoCmd.RunSQL "UPDATE[Table1] set[InUse] = '" & str9 & "' WHERE
[Stock
Num]
= '" & str1 & "'"

The error message is saying:
Syntax Error (missing operator) in query expression '[StockNum] = "ABC'"

Any help in determing what is wrong would be appreciated. Thanks for the
help....
 

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