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
MsgBox "Vendors in MasterCard_Source are confirmed"