With this technique, can actually pull data from worksheet into a query object or recordset without setting link with External Data wizard.
But then you have to modify the query for every file.
Four people have tried to help you with slightly different approaches. I will describe my approach again and if you think that will work for you I will help to implement it. Otherwise, I will go away.
a) you will need to modify your RawData table to include a BatchID. Follow along below.
b) You will need to create a new table to log batches. It contains 4 columns. BatchID (autonumber), LinkCount, AppendedCount, AppendDate (default to Now()
When I do this, I create the concept of a "batch". A batch is the set of records imported from any file. Here are the steps.
1. Create a record in the batch table to include the name of the source file. Include a column for the count. Save the record
2. Use TransferSpreadsheet to LINK the spreadsheet
3. Using dCount() run a query that counts the rows in the linked spreadsheet and updates the link count in the batch record. The query will take arguments.
4. Run an append query that appends the data in the linked spreadsheet to the RawData table.
5. Using dCount() run a query that counts the rows in the RawData table for the batch and updates the AppendedCount in the batch record.
6. Using a dCount() with criteria = "BatchID = " & Me.BatchID & " AND LinkCount <> AppendedCount"
If the last dCount returns 0, the counts match.
PS, I've never had a problem with losing records in the append so I think this is overkill. I still use the batch concept but only to tag the records for the batch and log the file name to prevent importing the same file more than once.