G
Guest
I'd be really grateful if someone could put me right on the following code,
intended to hide certain controls on an invoice report conditional on the
value of a check box. Trouble is the code hides the controls whatever the
value of the check box, and (as is no doubt all too obvious) I have only
miniscule knowledge of VBA.
I had somewhat similar code that worked (without the "Dim ckbIsAgent") to
hide controls for a form but a report seems to be a different kettle of fish.
I put in the Dim ckbIsAgent line when I got an error message saying I'd
entered an expression with no value and the debug highlighted the next line
(the "If..." line). No idea if that was correct.
Here's the code:
Private Sub Report_Open(Cancel As Integer)
Dim ckbIsAgent
If ckbIsAgent = True Then
txtOrderForAddress.Visible = True
lblAgentDiscount.Visible = True
txtAgentDiscount.Visible = True
txtAgentDiscountCalc.Visible = True
Else
txtOrderForAddress.Visible = False
lblAgentDiscount.Visible = False
txtAgentDiscount.Visible = False
txtAgentDiscountCalc.Visible = False
End If
End Sub
intended to hide certain controls on an invoice report conditional on the
value of a check box. Trouble is the code hides the controls whatever the
value of the check box, and (as is no doubt all too obvious) I have only
miniscule knowledge of VBA.
I had somewhat similar code that worked (without the "Dim ckbIsAgent") to
hide controls for a form but a report seems to be a different kettle of fish.
I put in the Dim ckbIsAgent line when I got an error message saying I'd
entered an expression with no value and the debug highlighted the next line
(the "If..." line). No idea if that was correct.
Here's the code:
Private Sub Report_Open(Cancel As Integer)
Dim ckbIsAgent
If ckbIsAgent = True Then
txtOrderForAddress.Visible = True
lblAgentDiscount.Visible = True
txtAgentDiscount.Visible = True
txtAgentDiscountCalc.Visible = True
Else
txtOrderForAddress.Visible = False
lblAgentDiscount.Visible = False
txtAgentDiscount.Visible = False
txtAgentDiscountCalc.Visible = False
End If
End Sub