RE: How do I use the INSERT INTO Statement in VBA?



try this
DoCmd.RunSQL "INSERT INTO tblBatch ([Batch #],[Entry Date]) VALUES
(Forms![frmLabourTransaction]![txtBatchUnbound],Forms![frmLabourTransaction]![TxtDateUnbound])"

When the fields name contain two seperate names you need to put then in
brackets
[]

"Unique Name" wrote:

> I modified the insert statement to reflect your posting but I am still
> getting an error:
>
> DoCmd.RunSQL "INSERT INTO tblBatch (Batch #,Entry Date) VALUES
> (Forms![frmLabourTransaction]![txtBatchUnbound],Forms![frmLabourTransaction]![TxtDateUnbound])"
>
> The error reads:
> Syntax error in INSERT INTO Statement.
>
> Thanks
>
> "Ofer" wrote:
>
> > Can you please post the all insert statement and the error you getting.
> >
> > The syntax should be
> > docmd.runsql "insert into target (Field1,Field2,Field3) values
> > (Forms![FormName]![Field1Name],Forms![FormName]![Field2Name],Forms![FormName]![Field3Name])"
> >
> > "Unique Name" wrote:
> >
> > > I am trying to enter data into a table from a form using the INSERT INTO
> > > Statement in VBA forAccess 2003. I type it as shown in the assistance(below)
> > > but keep getting errors. Is there something I am missing?
> > >
> > > INSERT INTO target [(field1[, field2[, ...]])]
> > > VALUES (value1[, value2[, ...])
> > >
> > > Thanks
.



Relevant Pages

  • RE: How do I use the INSERT INTO Statement in VBA?
    ... "Ofer" wrote: ... > When the fields name contain two seperate names you need to put then in ... >> Syntax error in INSERT INTO Statement. ... Prev by Date: ...
    (microsoft.public.access.modulesdaovba)
  • Re: syntax errors
    ... As Harvey indicates you have typed the second set of brackets from the ... You must either insert the Numpages field or use CTRL+F9 for the ... Word MVP web site http://word.mvps.org ... Word help tells which formula to use, but I get a syntax error every ...
    (microsoft.public.word.docmanagement)
  • Re: Fetching input character without newline?
    ... it's a syntax error. ... And I agree with it value in the brackets is ... Not proper usage of while loop. ... without causing the screen output to wrap. ...
    (comp.lang.perl.misc)
  • Re: ON ... AND statement problem
    ... long experience with SQL. ... it works with enough brackets. ... Finally because my different tests with WHERE gave me "syntax error" and ... clause I would try something else but would you be so kind to explain why, ...
    (microsoft.public.access.queries)
  • Re: call, ..= operator, records (newbie)
    ... On May 21, 4:04 pm, Martin Riener ... ERROR: Syntax error: Operator expected ... i guess that seperate ...
    (comp.lang.prolog)