Error in insert syntax

H

h3llz

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

whats wrong?
 
S

Stuart McCall

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.
 
S

Stuart McCall

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top