How to set visible parameter of a control on a report in VBA
Posted on 2014-01-23
From a separate VB module, I open a Report in acPreview mode (or acViewDesign mode), and attempt to set the visibility of a control based on the value of another control in the same report per the code below.
DoCmd.OpenReport SummaryReportName, acPreview, , "HHID = " & ClientNowPrinting
Debug.Print "This should print"
Debug.Print "Text135 = " & [RpQtr - Performance131231Charts]!Text135
Debug.Print "text199 visible = " & [RpQtr - Performance131231Charts]!Text199.Visible
If [RpQtr - Performance131231Charts]!Text135 <> 0 Then
[RpQtr -Performance131231Charts]!Text199.Visible = False
The Report loads fine, and subsequently prints, but my attempt to set control visibility before printing is fruitless. Any line of code having the name of the report just seems to be ignored, even the debug.print commands. The "This should print" line does print in the Immediate window, but the lines following do not print. The variable SummaryReportName = "RpQtr - Performance131231Charts"
Is it not possible to read the value in controls of a Report and change them from code in another module? If it is possible, what am I doing wrong?