Append values to Access table from excel with ID autogenerated

I have a access database with some tables which get updated daily with some values. I need the tables to have a ID field which is autogenerated when the other values of the table are imported from excel. I want to automate all by keeping a button and writing a VBA code. Right now I have a form which imports the value into the table, but it just imports the exact value which I have . I also need a extra column of ID that has to be auto generated when I import. Please help me.

Excel Sheet Sample:

ProductName | ProductValue

ABC | 76

SDF | 87


ID|ProductName| Product Value



Excel sheet updates each date with new value and it has to be put to the access db with ID automatically incremented.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

James ElliottManaging DirectorCommented:
You need to create a table in your Access DB that has ID (Autonumber) as the first field, then follow it with all of the fields from your spreadsheet.

You then need to append to this table when importing.
samsri25Author Commented:
I am not sure how it can be done in VB. So is there any code which can allow me to do it? I am able to append it while i manually import the data from excel when I use the tab "EXTERNAL DATA". I want to create a form with a button. On click of the button the value should be imported.
James ElliottManaging DirectorCommented:
What level of VBA understanding do you have?

The link shows how to connect to a DB and run an Insert statement. You'll have to build your own SQL string by looping through the records you want to insert.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
James ElliottManaging DirectorCommented:
You might consider adding your Excel file as a linked table and then using your button in Excel to simply trigger a pre-defined append query in Access. This would probably be cleaner.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.