Solved

Import only new records from an Excel file into an existing table

Posted on 2016-07-16
3
101 Views
Last Modified: 2016-07-17
Hi Experts

I'm needing to import a number of Excel files (separately) into existing tables in my database using VBA.

I can successfully do this with the DoCmd.TransferSpreadsheet however, I only want to add new records in each table.

As an example, the table "AdvParticipants" has a unique "userid" field and if the value in the column "userid" of the spreadsheet already exists in the field "userid" of this table, then skip it, otherwise import the record. I only need data to the last row and column in the spreadsheet imported.

And if possible, at the time of import, I would like to add 2 other fields which do not exist in the spreadsheet - [ImportDate] = "Now()" and Process Desc] = "Round1".

Any help would be appreciated.

Thanks
darls15
0
Comment
Question by:darls15
3 Comments
 
LVL 39

Assisted Solution

by:als315
als315 earned 250 total points
ID: 41715014
You can link Excel files instead of direct import and import data with query, where you can compare file with existing records and modify any field
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 41715025
alternatively, i would suggest to load the excel sheet into Staging Tables, validate the data there, and then load the data to the final tables. easier in the end...
0
 

Author Comment

by:darls15
ID: 41716112
Hi, thank you both for your suggestions. Using staging tables seem to be the way to go for my database. I'll award equal points for both these suggestions as they are both workable solutions. Thanks again :)
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

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