Two types of errors in SQL statement

  • Thread starter Afrosheen via AccessMonster.com
  • Start date
A

Afrosheen via AccessMonster.com

Thanks for reading this.

I'm getting two types of errors in my sql statement.

1) This has to deal with a name field I have. The last and first are
separated by a comma Like: Doe, James. Syntax error (comma) in query
expression 'Supervisor = Adams, Tim'

2) The second one has to do with an missing operator. Syntax error (missing
operator) in query expression 'Supervisor = Adams Tim'

This is the code: sql5 = "update tblMain set Supervisor = Null where
Supervisor = " & supname

What I'm trying to do is every record where "adams, tim" is will change to
null. The supname is selected from a combo box of Supervisors.

Thanks for your help.
 
A

Afrosheen via AccessMonster.com

Thanks again Dirk. You the man. It works perfectly.

BTW. Thanks for helping me out with the empty fields "Required". That works
great also.

Dirk said:
Thanks for reading this.
[quoted text clipped - 13 lines]
What I'm trying to do is every record where "adams, tim" is will change to
null. The supname is selected from a combo box of Supervisors.

A string literal must be enclosed in quotes. Try this:

sql5 = _
"UPDATE tblMain SET Supervisor = Null WHERE Supervisor = " & _
Chr(34) & supname & Chr(34)

That encloses the value of subname in double-quotes ("). The Chr(34)
function returns the double-quote character.
 
D

Dirk Goldgar

Afrosheen via AccessMonster.com said:
Thanks again Dirk. You the man. It works perfectly.

BTW. Thanks for helping me out with the empty fields "Required". That
works
great also.


I'm glad to 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