Insert all the rows without errors into a database called pipeline.mdb

Posted on 2005-03-05
Medium Priority
Last Modified: 2010-05-02
Hi Everyone I did a loop that checks the records from Excel for errors.  The records with errors go into an errors spreadsheet which I already did, but all the records without error need to be inserted into my database (pipeline.mdb)  
Can you guys help me with this?  Basically the entire row gets inserted into the database...I have an if statment that looks for the rows to be inserted but I don't know what code I can use to actually insert them...
Here's my code but of course it doesn't work.

for i = 1 to 14
    if (errors in the records)then 'pseudocode
    'put records into the excel spreadsheet --this part works, no problem
            'Database records without errors should be inserted into the database, I don't know how to do this?!?
             Dim RS As recordset
            Set CMD.ActiveConnection = Conn      
            CMD.CommandText = "INSERT * INTO COMPANY"
            CMD.CommandType = adCmdText
    End If
Next i
Question by:Angie532
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
LVL 10

Accepted Solution

PSSUser earned 2000 total points
ID: 13468567
needs to be replaced with
CMD.CommandText = "INSERT INTO COMPANY (Field1, Field2, ...,Fieldn) Values ('" & range("A" & i) & "','" & range("B" & i) & "',",...,",'" & range("N" & i) "')"

Expert Comment

ID: 13469743
or a simpler version:

the format of an insert command is:

INSERT INTO company (<comma delimited list of field names) VALUES (<comma demilited list of field values)

so the following:

INSERT INTO company (name,address,product) VALUES ("Microsoft","One Microsoft Way","software")

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

770 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