ColumnHidden brain freeze

  • Thread starter Thread starter RD
  • Start date Start date
R

RD

Hi all,

I'm trying to clean up some code on an old Access app and it's maiking
me crazy. In the Form_Open() event this gal has the following code:

Private Sub Form_Open(Cancel As Integer)

Me.Program.ColumnHidden = False
Me.Client_Lname.ColumnHidden = False
Me.Client_Fname.ColumnHidden = False
Me.DOB.ColumnHidden = False
Me.VRS.ColumnHidden = False
Me.JDS.ColumnHidden = False
Me.IWRP_6Mos.ColumnHidden = False
Me.AnnualPlan.ColumnHidden = False
Me.PhoneNo.ColumnHidden = False
Me.RefSE.ColumnHidden = False
Me.RefSEClosed.ColumnHidden = False
Me.AuxSvcs_AuthStart.ColumnHidden = False
Me.AuxSvcs_AuthEnd.ColumnHidden = False
Me.VocAssess_Closed.ColumnHidden = False
Me.VocAssess_Open.ColumnHidden = False
Me.VocAssess_Closed.ColumnHidden = False
Me.VocAssess_Open.ColumnHidden = False
Me.SA_AuthClosed.ColumnHidden = False
Me.SA_AuthOpen.ColumnHidden = False
Me.WA_AuthClosed.ColumnHidden = False
Me.WA_AuthOpen.ColumnHidden = False
Me.JD_AuthClosed.ColumnHidden = False
Me.JD_AuthOpen.ColumnHidden = False
Me.RehabClosed.ColumnHidden = False
Me.WC_AuthEnd.ColumnHidden = False
Me.WC_AuthStart.ColumnHidden = False
Me.DR_counselor.ColumnHidden = False
Me.WCStart.ColumnHidden = False
Me.WCEnd.ColumnHidden = False

End Sub

It seems to me that I should be able to loop through this and
accomplish the same thing with just a few lines of code but it's
kicking my @$$.

The form is viewed by the users as a datasheet and it's datasource is
a multitable SQL statement, not a nice little table. The form's name
is "frmUtilization".

I'm sure it's possible but these dang trees keep getting in the way of
the forest.

Many thanks for any help,
RD
"Sine labore nihil"
 
Hi,

You could do something like this:

Private Sub Form_Open(Cancel As Integer)

Dim ctrl As Control
Dim byteType As Byte

For Each ctrl In Me.Controls
byteType = ctrl.Properties("ControlType")
If byteType = acCheckBox Or byteType = acComboBox Or byteType =
acTextBox Then
ctrl.ColumnHidden = False
End If
Next ctrl

End Sub

Clifford Bass
 
Back
Top