Strictly speaking this isn't a problem with a query but rather an insert into a table. I have created an Insert statement by concatenating key words, the name of the table plus all its columns (belt and suspenders approach to cover my arse!) and the values from multiple form controls. Then I try to run the statement with a DoCmd.RunSQL("txt_SQLStmt") command. At this point I get Run-time Error 3129 Invalid SQL Statement.
The code in the click event for the Save button is as follows...
Dim Txt_SQLStmt As String
Txt_SQLStmt = "INSERT INTO ICTAssets (EdQuipNo, WorkStationNo, ItemType, ItemClass, Serial/ServTag, LocationBlock, " & _
"LocationRoom, Manufacturer, Model, PurchaseDate, WarrantyEnd, Description, Deleted) VALUES ('" & _
Me![EdQuipNo].Value & "', '" & Me![txt_WorkStationNo].Value & "', " & _
Me.ComboItemType.Value & ", " & Me.ComboItemClass.Value & ", '" & Me![Txt_SerialServTag].Value & "', " & _
Me.ComboLocationBlock.Value & ", " & Me.ComboLocationRoom.Value & ", " & Me.ComboManufacturer.Value & ", " & _
Me.ComboModel.Value & ", #" & Me![Dte_Purchased].Value & "#, #" & Me![Dte_WarrantyEnd].Value & "#, '" & _
Me![Txt_Description].Value & "', " & False & ");"
MsgBox (Txt_SQLStmt)
DoCmd.RunSQL ("Txt_SQLStmt")
At first I declared Txt_SQLStmt as a Variant but that didn't seem to matter.
Have I left something out? Or is it simply a syntax error that I can't see for looking at it for waaaaayyyyy toooooo long?
Further, the data seems to be getting sent to the table despite the error message, however, to see the changes I have to log out of Access and back in again. I don't know if that is related to the error message because I am new to Access and it doesn't seem to work at all like SQL Server, Oracle, Sybase, MySQL or Ingres - the RDBMSs I have used previously.
Thanks in advance