Record Import Message

amerfeld

Registered User.
Local time
Today, 08:22
Joined
Aug 17, 2004
Messages
58
I have a form with a button, which when clicked, imports a table from excel. This works fine. However, I am wondering if there is a way to notify the user of the number of records that were imported. If so, how? Thanks for any help.
 
If you will always have an empty table that you import to, this function will work. If not, you will need to modify it to account for the records already in the table.

Function ImportData()
On Error GoTo ImportData_Err

Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim intCount As Integer
Dim strMsg As String

DoCmd.TransferSpreadsheet acImport, 8, "tblTestImport", "c:\testimport.xls", True, ""
Set db = CurrentDb
Set rst = db.OpenRecordset("tblTestImport")
intCount = rst.RecordCount
MsgBox "Imported " & intCount & " records."

ImportData_Exit:
Exit Function

ImportData_Err:
MsgBox Error$
Resume ImportData_Exit

End Function


HTH :cool:
 
If you import the records into an empty temp table than a simple DCount will work...

Code:
MsgBox DCount("*", "YourTempImportTableNameHere") & " records were imported.", vbInformation, "Import Completed"
 
Thanks!

Was able to use gh's suggestion and works perfectly. Thanks so much for both or you time and help!!
 

Users who are viewing this thread

Back
Top Bottom