BTW, a simpler way to do this would be to make this a callable routine:
Public Sub SwitchControls(pFrm as Form, pblnEnable as boolean)
Dim ctl as Control
For each ctl in pFrm.Controls
If TypeOf ctl is Form then
Call SwitchControls(ctl, pblnEnable)
ElseIf TypeOf ctl is TextBox or TypeOf ctl is ComboBox
With ctl
.Locked = not pblnEnable
.Visible = pblnEnable
End With
Else
Msgbox "I forgot to handle this type of control!"
End If
Next ctl
End Sub
To enable controls, in your form make this call from code in your form:
Call SwitchControls(Me,True)
To disable controls:
Call SwitchControls(Me,False)
NOTE: Doing this will automatically handled nested SubForms to any depth allowed by Access.
QED
Randall J Weers
Membership Vice President
Pacific NorthWest Access Developers Group
http://www.pnwadg.org