troubleshooting Question

DCount Value Ignored in IF Statement

Avatar of Haiden Turner
Haiden TurnerFlag for United States of America asked on
Microsoft Access
14 Comments1 Solution402 ViewsLast Modified:
I have some code that tests for three error producing conditions with a simple If statement that if True opens a report showing the erroneous elements in the data and if False advances to the next test.

All three tests are essentially the same: if Dcount of a select query is greater than Zero it is a True and the report is opened, if not greater than zero advance to the next test.

The first and second test work as expected, but the third test opens the report, which is blank.

Running the select query for the third test returns no results and running Debug.Print DCount("*", "qryVendorNotInQB") in the immediate windows returns a zero.

'Test to see if any vendors in the MasterCard_Source are not in QuickBooks
    If DCount("*", "qryVendorNotInQB") > 0 Then
    'Open report displaying missing/erroneous vendors
    DoCmd.OpenReport "rptVendorsNotFoundInQB", acViewPreview
    DoCmd.SetWarnings True
    Exit Sub
    MsgBox "Vendors in MasterCard_Source are confirmed"
    End If

Open in new window

Join our community to see this answer!
Unlock 1 Answer and 14 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 14 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros