I am trying to use the DoCmd.RunSQL command to add a new record to an existing table. The code is attached to a button and is as follows:
strSQL = "INSERT INTO RoomItemDetails (Roomref, QuoRef, ProductItemRef, Ordered) VALUES (intRoomid, [Quote Ref], '5', true)"
DoCmd.RunSQL strSQL
In VALUES, intRoomID is a declared integer variable holding an integer value; [Quote Ref] is a field known to this form; '5' is a string and true is a boolean Y/N state.
The programme doesn't seem to like the variable intRoomID, as it puts up a message box asking for it, but works as planned when this is given. I have tested that the variable gets the number; I populate the variable by using the output from a recordset of a table using rstTable(0): I have also tried using this in the Values section instead of intRoomID, but it thinks it is an undeclared function.
Has anyone any ideas please?
regards
Roger