troubleshooting Question

DCount Value Ignored in IF Statement

Avatar of haident
haidentFlag 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
    Else
    MsgBox "Vendors in MasterCard_Source are confirmed"
    End If
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 14 Comments.
Join the Community
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