How to reference controls on an open Report

David_W_R used Ask the Experts™
This code segment opens a report with the name "rpQtr-Performance150930QTR-ex" and needs to test the value of a textbox on the Report to determine whether to print the report.  The "If Reports!..." statement doesn't appear to be working.  I halted execution and stepped thru the code to confirm that VB doesn't recognize the format I used.

When I test it in the Immediate window, I get the error:  "You entered an expression that has no value"

DoCmd.OpenReport QtrNonBillableReportName, acViewPreview, , "HHID = " & ClientNowPrintingDoCmd.RunCommand acCmdPreviewFourPages

If PauseBeforeClosingSection Then MsgBox ("Proceed")
If Not ViewOnly Then
       If Reports![rpQtr-Performance150930QTR-ex].txtQTRbegin <> 0 And Me!txtQTRbegin <> 0 Then
           Totalpages = Reports(QtrNonBillableReportName).Pages
            DoCmd.PrintOut acPages, 2, Totalpages - 1, acHigh
      End If
End If
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016
use a dlookup() function using the reports Record Source to test for the value, prior to opening of the report

if dlookup("QTRbegin", "< Record source Of Report>",<criteria here>) <> 0  etc....


Thanks for the guidance.  Who knew one could not address and use Report control values!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial