Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1074811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:11:11+00:00 2026-05-16T21:11:11+00:00

I have an excel invoice sheet and I want to write the information from

  • 0

I have an excel invoice sheet and I want to write the information from the invoice to a table in an Access file. My following code is:

Private Sub Button66_Click()
Dim con As New ADODB.Connection
Dim connectionString As String

Dim sql As String

connectionString = "DBQ=c:\Users\Public\Public Desktop\InvoiceRecords.mdb; Driver={Microsoft Access Driver (*.mdb)};"

con.Open connectionString

sql = "insert into Invoices (Customer, Address) values(G6, G7)"

con.Execute sql

MsgBox "Values entered", vbInformation

con.Close

Set con = Nothing

End Sub

However, when I run it I get a runtime-error ‘-2147217904 (80040e10)’; Too few parametersentered.
I’m not what sure what this is.
Any ideas or suggestions? Thanks a bunch!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T21:11:12+00:00Added an answer on May 16, 2026 at 9:11 pm

    I think the problem is you’re trying to get at the values of cells G6 and G7 in your INSERT query. You need to concatenate them into your insert query instead.

    sql = "insert into Invoices (Customer, Address) " & _
        "values('" & Range("G6") & "', '" & Range("G7") & "')"
    

    Building your sql commands this way makes you vulnerable to SQL injection. A better alternative is to use a parameterized query.

    Dim cmdInsert As New ADODB.Command
    With cmdInsert
        .Prepared = True
        .CommandType = adCmdText
        .CommandText = "INSERT INTO Invoices (Customer, Address) VALUES (?, ?)"
        Set .ActiveConnection = con
    End With
    
    cmdInsert.Parameters(0).Value = Range("G6").Value
    cmdInsert.Parameters(1).Value = Range("G7").Value
    cmdInsert.Execute
    

    You should also use the Jet driver to connect, instead of the ODBC driver. Use this connection string instead.

    "Provider=Microsoft.Jet.OLEDB.4.0;Data source=c:\Users\Public\Public Desktop\InvoiceRecords.mdb;"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a excel file with a bunch of sheets. The first sheet is
I'm new to c#.net I have excel sheet and I want to import into
I have excel sheet with data which I want to get Levenshtein Distance between
I have excel file with following columns Field1 Field2 Field3, Field4 =============================== 123 4
I have wrote a code that can read an excel 2007 file using Microsoft
Is it possible to extract information from an excel file (.xls) into c# on
I have Excel file and some contents, coming from external source(database, file, whatever). I've
I have an Excel file that I need to import into a (new) Oracle
I have an Excel spreadsheet that uses a TFS query to pull information on
I have an Excel table with some data that I would like to export

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.