Access/VBA

T

Trentongg

I have a sub routine that is called from a form that imports a spreadsheet
and adds the records to an existing table. Each time I import a spreadsheet
to the table I need to count how many records were imported. I was able to
do this by creating a dup table to hold just the new records and then run a
query on this table to count the records. Isn't there a better way to do
this in a sub routine?
 
B

Bob Hairgrove

I have a sub routine that is called from a form that imports a spreadsheet
and adds the records to an existing table. Each time I import a spreadsheet
to the table I need to count how many records were imported. I was ableto
do this by creating a dup table to hold just the new records and then run a
query on this table to count the records. Isn't there a better way to do
this in a sub routine?

There's no need for an additional table here. In your event procedure,
I suggest you call the DCount function once before importing the
records, store the count in a variable, and call it once again after
the import finishes. Then you can just subtract the first count from
the second.
 
J

John Vinson

I have a sub routine that is called from a form that imports a spreadsheet
and adds the records to an existing table. Each time I import a spreadsheet
to the table I need to count how many records were imported. I was able to
do this by creating a dup table to hold just the new records and then run a
query on this table to count the records. Isn't there a better way to do
this in a sub routine?

I'd suggest linking (rather than importing) the spreadsheet; counting
the records just with DCount; and running an Append query.

John W. Vinson[MVP]
 
Top