Hi Klatuu,
Maybe I'm missing something, but your description:
Create an append query that will copy the data from the spreadsheet to the
table. [snip]
Then, rather than importing the spreadsheet, Link to it.
Run the Append Query.
Delete the Excel Link (Use the DeleteObject method)
seems backwards to me. How can you create the query if you haven't
created the linked table from which it gets its data?
So I think we're doing basically the same thing:
Create a temporary table (temporary in the sense that it will
be deleted once the data has been appended to the table where
it's needed). This can be either a linked table or a "real" one.
Use an append query to move the data.
Delete the temporary table
As for linking vs importing, linking is neater in principle, but I've
often had problems because the Excel ISAM uses different rules to assign
field types when linking and when importing. So I tend to try one, and
if that doesn't bring in all the data I try the other, and if that
doesn't work either add apostrophes to text fields or export from Excel
to a text file.
Importing does increase the size of the mdb, but compacting seems to
reduce it again. And with the limit of 64k rows in Excel we're not
dealing with big tables anyway.
John,
I would appreciate your thoughts on the preference for Linking or Importing.
My preference is to Link. My thought is, although not substantiated by any
testing, is that importing will create more bloat in the database. I also
think it is more time efficient, because data has to be moved only once with
a link.
I noticed you included a temporary table in your solution. Is that
necessary? If you do an append query on a table that has an auto number
field will it not also create new autonumbers for the appended records?
Please understand, this is not a dispute, but a learning exercise for me.
When I see a technique different that one I use, I like to have a comparison
of the techniques.