Private Sub HideMultiUnitflds()
Dim ctl As Control
Dim nfrmSub As SubForm
Dim nMU As Boolean
nMU = Me.MultiUnit.Value
If nMU = True Then
For Each ctl In Me.Controls
If ctl.Tag = "HC" Then
' Debug.Print ctl.Name
' If ctl.Visible = True Then
Me.pg_RentComps.Visible = False
Me.pg_SubjUnits.Visible = False
Me.txtValuePerUnit.Visible = False
Me.txtUnits.Visible = False
ctl.Visible = False
'Else
Me.pg_RentComps.Visible = True
Me.pg_SubjUnits.Visible = True
ctl.Visible = True
'End If
End If
Next
End If
End Sub
Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.
TRUSTED BY
ASKER
Here is my final code.
Private Sub HideMultiUnitflds()
Dim ctl As Control
Dim nMU As Boolean
Dim stag As String
' certain fields are to be visible only if multi-unit is checked
' is multi-unit checked?
nMU = Nz(Me.MultiUnit.Value, False)
For Each ctl In Me.Controls
stag = ctl.Tag
If stag = "HC" Then
ctl.Visible = nMU
End If
Next
Me.frm_SalesComps_sub.Form
For Each ctl In Me.frm_SalesComps_sub.Form
stag = ctl.Tag
If stag = "HCSub" Then
ctl.Visible = nMU
End If
Next
End Sub