Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Error in insert syntax

Geek News

Error in insert syntax
h3llz 12/4/2008 11:17:02 AM
qryString = "INSERT INTO tblProductsLog
(staffID,productID,quantity,timestamp) VALUES ('" & staffID & "','" &
txtProductID.Caption & "','-" & cmoSelectQuantity.Text & "','" & Now() & "');"

whats wrong?
Re: Error in insert syntax
"Stuart McCall" <smccall[ at ]myunrealbox.com> 12/4/2008 11:41:42 AM
"h3llz" <h3llz[ at ]discussions.microsoft.com> wrote in message
news:D9C1AC92-8DA9-4C12-AFE7-37D52033B85B[ at ]microsoft.com...
[Quoted Text]
> qryString = "INSERT INTO tblProductsLog
> (staffID,productID,quantity,timestamp) VALUES ('" & staffID & "','" &
> txtProductID.Caption & "','-" & cmoSelectQuantity.Text & "','" & Now() &
> "');"
>
> whats wrong?

Lose the quotes surrounding the Now() function.


Re: Error in insert syntax
h3llz 12/4/2008 11:52:01 AM
How do i execute the qryString?
Mydb.OpenRecordset (qryString)
is wrong i assume

"Stuart McCall" wrote:

[Quoted Text]
> "h3llz" <h3llz[ at ]discussions.microsoft.com> wrote in message
> news:D9C1AC92-8DA9-4C12-AFE7-37D52033B85B[ at ]microsoft.com...
> > qryString = "INSERT INTO tblProductsLog
> > (staffID,productID,quantity,timestamp) VALUES ('" & staffID & "','" &
> > txtProductID.Caption & "','-" & cmoSelectQuantity.Text & "','" & Now() &
> > "');"
> >
> > whats wrong?
>
> Lose the quotes surrounding the Now() function.
>
>
>
Re: Error in insert syntax
"Stuart McCall" <smccall[ at ]myunrealbox.com> 12/5/2008 12:39:43 AM
"h3llz" <h3llz[ at ]discussions.microsoft.com> wrote in message
news:D24B8560-60F2-4FBF-AB98-8B50B0ED0D96[ at ]microsoft.com...
[Quoted Text]
> 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.


Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net