Link to home
Start Free TrialLog in
Avatar of thutchinson
thutchinsonFlag for United States of America

asked on

Use MsgBox to display the number of records imported

DCount-example.txt

Hi Experts,

I have a module that imports invoice line item details from an Excel file.  At the completion of the import I would like to display the number of records successfully imported into a table named "Invoices".  I was using the ImportDate field to specify the records to count.  Here's what I was trying:

 'MsgBox DCount("*", "Invoices", "ImportDate = #" & Date & "#") & " records imported into Invoices table", vbInformation, "Import"

The MsgBox returns "0 records imported into Invoices table" which is incorrect. All records are being imported correctly.  Is someone able to help me with my syntax?  The full text of the module is attached in case anyone wishes to offer additional comments or improvements.  Thanks.
ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also, IF ... Date actually contains time (?), then try this:


MsgBox DCount("*", "Invoices", "ImportDate = #" & DateValue([Date]) & "#") & " records imported into Invoices table", vbInformation, "Import"

This assumes Date cannot be Null ...
Avatar of thutchinson

ASKER

Hi DatabaseMX.  

Your suggestion didn't work.  In fact, now I don't get the Msgbox at all.  Instead the error trapping message kicks in and says it doesn't recognize a field (although all records were imported successfully.