Link to home
Start Free TrialLog in
Avatar of samsri25
samsri25

asked on

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

DATABASE TABLE

ID|ProductName| Product Value

1|ABC|76

2|SDF|87

Excel sheet updates each date with new value and it has to be put to the access db with ID automatically incremented.
Avatar of James Elliott
James Elliott
Flag of United Kingdom of Great Britain and Northern Ireland image

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.
Avatar of samsri25
samsri25

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of James Elliott
James Elliott
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.