Solved

Insert into table

Posted on 2014-02-13
3
229 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!

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
How to install and configure Citrix XenApp 6.5 - Part 1. In this video tutorial we have explained step by step installation of Citrix XenApp 6.5 Server on Windows Server 2008 R2 is explained in this video. We have explained the difference between…

758 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

22 Experts available now in Live!

Get 1:1 Help Now