Syntax issue with DoCmd.RUNSQL

mrheffner

Registered User.
Local time
Today, 07:02
Joined
Jul 29, 2019
Messages
10
Hello, Please help.


I am trying to make a copy of a record into the same table. When this is complete it will be a feature which allows my users to create Template records which can then be used when creating work orders.


I am getting a syntax error on the INSERT INTO. I can't see what I am doing wrong.


Here is the code:
Code:
    SQL = "INSERT INTO [t_Material Consumed]([Material Name], [Color#], Percent) " & _
          "SELECT [Material Name], [Color#], Percent " & _
          "FROM [t_Material Consumed] " & _
          "WHERE ([Consuming Work Order] = '" & currentID & "');"
          
    MsgBox (SQL)
 
    DoCmd.RunSQL SQL
I uploaded an attachment with the info from the MsgBox. Any help would be greatly appreciated.


Btw, the fields included are not everything. I just included those to keep it simple while debugging.


Mike
 

Attachments

  • MsgBoxCapture.JPG
    MsgBoxCapture.JPG
    32 KB · Views: 91
Hi. Maybe "Percent" is a reserved word. Try enclosing it in brackets, e.g. [Percent]. Hope it helps...
 
IDs are normally numeric, you have yours as text? Is it text?

A display of the MSGBOX SQL would help?
 
It was the [Percent]. It is working now. The other suggestions were also helpful. Thanks to everyone.
 
It was the [Percent]. It is working now. The other suggestions were also helpful. Thanks to everyone.
Hi. Congratulations! Glad to hear you got it to work. We were all happy to assist. Good luck with your project.
 

Users who are viewing this thread

Back
Top Bottom