Error in insert syntax

  • Thread starter Thread starter h3llz
  • Start date Start date
H

h3llz

qryString = "INSERT INTO tblProductsLog
(staffID,productID,quantity,timestamp) VALUES ('" & staffID & "','" &
txtProductID.Caption & "','-" & cmoSelectQuantity.Text & "','" & Now() & "');"

whats wrong?
 
h3llz said:
qryString = "INSERT INTO tblProductsLog
(staffID,productID,quantity,timestamp) VALUES ('" & staffID & "','" &
txtProductID.Caption & "','-" & cmoSelectQuantity.Text & "','" & Now() &
"');"

whats wrong?

Lose the quotes surrounding the Now() function.
 
h3llz said:
How do i execute the qryString?
Mydb.OpenRecordset (qryString)
is wrong i assume

Either:

CurrentDb.Execute qryString, dbFailOnError

which will run without prompting the user, plus errors can be trapped.

or:

DoCmd.RunSQL qryString

which will (by default) ask user to confirm the action.
 
Back
Top