Solved

Insert into table

Posted on 2014-02-13
3
234 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 50

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
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…

730 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