A
alex
Using Access ’03…
With the help of an article from Michael Kaplan, I have the following
code that will hide/unhide columns on a subform:
Private Sub Form_Load()
Dim ctl As Control
Dim stCtl As String
Set sfrm = Me.sfrmHideShowColumns
For Each ctl In Me.Controls
If TypeOf ctl Is Access.CheckBox Then
stCtl = "tb" & Mid$(ctl.Name, 3)
ctl.Value = Not sfrm.Form(stCtl).ColumnHidden
End If
Next ctl
End Sub
---------------------------------------------------------------------------------
Private Function ShowHideColumn()
Dim sfrm As SubForm
Dim ctl As Control
Dim stCtl As String
Set sfrm = Me.sfrmHideShowColumns
For Each ctl In Me.Controls
If TypeOf ctl Is Access.CheckBox Then
stCtl = "tb" & Mid$(ctl.Name, 3)
sfrm.Form(stCtl).ColumnHidden = _
Not ctl.Value
End If
Next ctl
End Function
This code, however, relates a checkbox to a specific textbox/column
(both named the same). I need code such that when a checkbox is
checked, >1 column is hidden/unhidden. In addition, I’d like a
checkbox to hide/unhide all columns. I cannot seem to modify the code
in such a way to do this. I basically need to relate a checkbox to
multiple textboxes.
Any help would be appreciated.
alex
With the help of an article from Michael Kaplan, I have the following
code that will hide/unhide columns on a subform:
Private Sub Form_Load()
Dim ctl As Control
Dim stCtl As String
Set sfrm = Me.sfrmHideShowColumns
For Each ctl In Me.Controls
If TypeOf ctl Is Access.CheckBox Then
stCtl = "tb" & Mid$(ctl.Name, 3)
ctl.Value = Not sfrm.Form(stCtl).ColumnHidden
End If
Next ctl
End Sub
---------------------------------------------------------------------------------
Private Function ShowHideColumn()
Dim sfrm As SubForm
Dim ctl As Control
Dim stCtl As String
Set sfrm = Me.sfrmHideShowColumns
For Each ctl In Me.Controls
If TypeOf ctl Is Access.CheckBox Then
stCtl = "tb" & Mid$(ctl.Name, 3)
sfrm.Form(stCtl).ColumnHidden = _
Not ctl.Value
End If
Next ctl
End Function
This code, however, relates a checkbox to a specific textbox/column
(both named the same). I need code such that when a checkbox is
checked, >1 column is hidden/unhidden. In addition, I’d like a
checkbox to hide/unhide all columns. I cannot seem to modify the code
in such a way to do this. I basically need to relate a checkbox to
multiple textboxes.
Any help would be appreciated.
alex