I am working on an Access DB. The data source for this DB is Excel spreadsheets. I need to add functionality that will allow a user to clean the raw Excel data by running a VBA function and then import this data into Access, without importing duplicate records.
I have a few questions about how to approach this:
1) Should I write a VBA procedure and a simple GUI in Excel to clean the data, or should I include this in an Access Form that allows the user to import Excel data into a table? In other words, should the data be cleaned in Access or outside of Access?
2) What is the best way to prevent the import of duplicate records into a table? Should I write VBA code to do this, or should I set a property of the table (if this is possible)?
3) Should I allow the user to clean the data in Excel and then just have the user use an import wizard in Access to add the data instead of writing code in a Form to allow the import of data into a data table?
Thanks!
The best way to prevent duplicate records in the database is to define a unique index on the column(s) that constitute(s) a unique key.
For example, if you wanted to make sure that there was no more than one specialist per speciality per hospital in the hospital system, you could do this in a hypothethetical HospitalSpecialists table:
Then you couldn’t insert a duplicate.
So you first have to determine what constitutes a duplicate for your table: which subset of the columns, when taken together, establishes the uniqueness of the record?