Solved

Insert into table

Posted on 2014-02-13
3
230 Views
Last Modified: 2014-02-14
Hi,

this is VB access database.  I can insert one record but if I try to insert more than one I get a systax error.

I am not sure why.

This will insert fine for one record.

CurrentDb.Execute "INSERT INTO [Report_1_MTD_Daily_Containment] ([LOB], [CreatedDate], [Call_Count], [Contained_Calls])" _
& "(,'WMI', #" & MyDate & "#, '" & WMICount & "', '" & WMIContained & "');"

I want to do this:

CurrentDb.Execute "INSERT INTO [Report_1_MTD_Daily_Containment] ([LOB], [CreatedDate], [Call_Count], [Contained_Calls])" _
& "VALUES ('DC', #" & MyDate & "#, '" & DCCount & "', '" & DCContained & "')" _
& "(,'WMI', #" & MyDate & "#, '" & WMICount & "', '" & WMIContained & "');"

it says missing semicolon

Thanks,
Lulu
0
Comment
Question by:lulu50
3 Comments
 
LVL 49

Assisted Solution

by:Gustav Brock
Gustav Brock earned 250 total points
ID: 39857462
You can't do that. You have to run the query twice with one set of values.

Or use DAO and VBA. Much nicer and cleaner.

/gustav
0
 
LVL 19

Accepted Solution

by:
Ken Butters earned 250 total points
ID: 39857483
I think are you trying to insert two rows worth of data?

If so... I believe that needs to be separated into two insert statements.

Also noticed on your last line... a leading comma right after the open parenthesis...

Corrected statements should be something like this:

CurrentDb.Execute "INSERT INTO [Report_1_MTD_Daily_Containment] ([LOB], [CreatedDate], [Call_Count], [Contained_Calls]) " _
& "VALUES ('DC', #" & MyDate & "#, '" & DCCount & "', '" & DCContained & "')";

CurrentDb.Execute "INSERT INTO [Report_1_MTD_Daily_Containment] ([LOB], [CreatedDate], [Call_Count], [Contained_Calls]) " _
& "VALUES ('WMI', #" & MyDate & "#, '" & WMICount & "', '" & WMIContained & "');"
0
 

Author Closing Comment

by:lulu50
ID: 39858857
Thank you
0

Featured Post

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now