Home > Back-end >  error 3075 running SQL to insert into table, what am I missing?
error 3075 running SQL to insert into table, what am I missing?

Time:10-13

Getting a run-time error when running the following command:

mySQL = "INSERT INTO incidentlog (mon, yr, observation) VALUES (" & Me.Combo37.Column(0) & ", " & Me.Combo39.Column(0) & ", " & Me.Combo10.Column(0) & ": " & Me.Text12 & "" & vbCrLf & "--" & Me.Combo35 & "" & Me.Combo37 & "" & Me.Combo39 & "/" & Me.Combo18 & "/" & Me.Text16 & "/COR " & Me.Text21 & " " & Me.Combo25.Column(2) & ")"
Debug.Print mySQL
DoCmd.RunSQL mySQL

debug prints right, but I can't seem to figure out where the issue is. combo35, combo39, and text16 are all numerical fields.

debug print (edited information out):

INSERT INTO incidentlog (mon, yr, observation) VALUES (Jan, 2022, PO-02: EDITED OUT.
--01Jan2022/EDITED OUT/0700/COR my notes here USER)

CodePudding user response:

As the last field, observation, is text, you need to wrap it in single quotes:

mySQL = "INSERT INTO incidentlog (mon, yr, observation) 
VALUES (" 
& Me.Combo37.Column(0) & ", " 
& Me.Combo39.Column(0) & ", '" 
& Me.Combo10.Column(0) & ": " & Me.Text12 & "" & vbCrLf & "--" & Me.Combo35 & "" & Me.Combo37 & "" & Me.Combo39 & "/" & Me.Combo18 & "/" & Me.Text16 & "/COR " & Me.Text21 & " " & Me.Combo25.Column(2) 
& "')"
  • Related