[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 610
  • Last Modified:

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.
0
thutchinson
Asked:
thutchinson
  • 2
1 Solution
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Try brackets around the field name (?) Date, because Date is a Reserved Word ...

MsgBox DCount("*", "Invoices", "ImportDate = #" & [Date] & "#") & " records imported into Invoices table", vbInformation, "Import"
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
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 ...
0
 
thutchinsonAuthor Commented:
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.
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now