Reputation: 428
I have a checkbox control that i need to hide if a Boolean value is false. I have tried using the Detail_Format event to no avail. i put the field value into another checkbox, then tried setting the visible property from the value in the checkbox, no dice. In the image below, the rightmost checkbox is showing the value of the field that determines if the checkbox to the left of it should be shown. I have the following code
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.chkRequireverify = True Then
Me.chkVerified.Visible = True
Else
Me.chkVerified.Visible = False
End If
'Me.chkVerified.Visible = Me.chkRequireverify
End Sub
when i tried using the Detail_Paint event, it errored out telling me that i cant change the visible property in this event.
Upvotes: 2
Views: 1181
Reputation: 16025
Your code looks to be correct and could be shortened to simply:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.chkVerified.Visible = Me.chkRequireverify
End Sub
However, I believe the event handler for the OnFormat
event will only be evaluated when viewing the report in Print Preview view, rather than in Report view.
Whilst the OnPaint
event fires in Report view, you cannot modify certain properties after the report has been formatted, the Visible
property being one such property, along with the Height
& Width
properties (and so you also cannot shrink the checkboxes to zero size).
Upvotes: 1
Reputation: 992
It's been a while since I've used Access and VBA, but I believe what you're missing is .Value
after the checkbox name in the if
clause.
Try this : If Me.chkRequireverify.Value = True
Upvotes: 0