Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DoCmd.RunSQL problem

Status
Not open for further replies.

JB83

Programmer
Oct 3, 2002
44
NL
Dear reader(s),

I have a problem with DoCmd.RunSQL: when I want to add a record in a table with a WHERE-clause I get a syntax error, and I don't know how to solve the problem.

Code:
DoCmd.RunSQL ("INSERT INTO [tblReasons] (Reason1, Reason2, Reason3, Reason4, Reason5, Reason6) 
SELECT " & defReason & " , " & defReason & " , " & defReason & ", " & defReason & " , " & defReason & " , " & defReason & " WHERE docNumber = txtDocNumber.Value")

Thanks in advance,

Jochen. --------------------------------------------------------------------------------
It never hurts to help and it never helps to hurt.
 
Try
.................................
SELECT " & defReason & " , " & defReason & " , " & defReason & ", " & defReason & " , " & defReason & " , " & defReason & " WHERE docNumber = " & txtDocNumber & ")
 
JB83,

You really shouldn't cross-post your questions, I also have answered this in your thread: thread701-477265

It may be helpful to read the thread that JeremyNYC posted on how to get good answers thread181-473997.

Anthony J. DeSalvo
President - ScottTech Software
"Integrating Technology with Business"
 
Thanks for all the help, but I found a solution myself.

Keep up the good work!

[2thumbsup] --------------------------------------------------------------------------------
It never hurts to help and it never helps to hurt.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top