Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to hide a checkbox and name field if it is empty in a report? 1

Status
Not open for further replies.

ffleitas

Technical User
Mar 15, 2001
85
US
Hello programmers,

I have this code in the detail section of the report. The problem is that all the checkboxes are not visible eventhough they have check marks. What can I change to make the checkboxes that are checked to be visible and of course the not checked not visible?

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim ctrl As Control
For Each ctrl In Me.Controls
If TypeOf ctrl Is CheckBox Then
With ctrl
.Visible = False
End With
End If
Next ctrl
End Sub


Regards,
Felix
 
your problem is that you are setting the control to Visible = False but not setting it back to Visible when it is checked
try changeing code in red
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Dim ctrl As Control
    For Each ctrl In Me.Controls
        If TypeOf ctrl Is CheckBox Then
            With ctrl
                .Visible = [COLOR=red]nz(ctl,0)[/color]
            End With
        End If
    Next ctrl
End Sub
 
Hi pwise,

I added the red data but it still does not show. Let me know?

Felix
 
Hi pwise,

I noticed that the ctl was misspelled. Thank you it worked.

 
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Dim ctrl As Control
    For Each ctrl In Me.Controls

        If  [COLOR=red]ctrl.ControlType =acCheckBox [/color] Then
            With ctrl
                .Visible = nz(ctl,0)
            End With
        End If
    Next ctrl
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top