?
Solved

Insert into table

Posted on 2014-02-13
3
Medium Priority
?
238 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 51

Assisted Solution

by:Gustav Brock
Gustav Brock earned 1000 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 1000 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
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.
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Suggested Courses

777 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