Count # of Records

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a macro that imports data with specs for a user. Is there a way to
say..."You've imported 400 records?" If it means creating an on-click event
that's find, but what would the code be for counting the records?
Thanks,
Sash
 
Hi Sash,

The built-in RecordsAffected property can be used for this sort of
thing, but the TransferText macro action and DoCmd method don't update
it.

So one possibility is to count the number of records in the table before
and after the import and report the difference, e.g.

Dim RecCountBefore As Long, RecCountAfter As Long

RecCountBefore = DCount("*", "MyTable")
DoCmd.TransferText blah blah
RecCountAfter = DCount("*", "MyTable")
MsgBox "blah blah " & RecCountAfter - RecCountBefore & " records."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top