Help please - determine the number of records appended

F

FatMan

Hi all:
Is there a way to determine the number of records that will append to a
table with an append query? I have an excel table that I have linked into my
database that I am appending the records to a table. I am doing this through
code and have set the warnings off but need some way to inform the user the
number of records appended. What I would like to do is determine the number
of records in the linked excel file and compare it to the number of records
appended.

Can this be done?

Any help is greatly appreciated,
FatMan
 
D

Douglas J. Steele

Assuming you use the Execute method of the Database object, there's a
RecordsAffected property you can check.

Dim dbCurr As DAO.Database
Dim strSQL As String

strSQL = "INSERT INTO Table1 (Field1, Field2, Field3) " & _
"SELECT Table2.Field1, Table3.Field2, Table3.Field3 " & _
"FROM Table2 INNER JOIN Table3 " & _
"WHERE Table2.Field1 = Table3.Field1"

Set dbCurr = CurrentDb()
dbCurr.Execute strSQL, dbFailOnError
MsgBox "You just appended " & dbCurr.RecordsAffected & " rows."

Set dbCurr = Nothng
 

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

Top