Private Sub EnableControls(EnabledState As Boolean, ParamArray ControlList() As Variant) '------------------------------------------------------------------ 'Enables or disables form controls. '------------------------------------------------------------------ ' Inputs: EnabledState - True = enable controls ' - False = disable controls ' ControlList - A paramarray of controls to enable/disable '------------------------------------------------------------------ Dim ctl As Control Dim intIndex As Integer On Error Resume Next 'Caters for controls that can't be disabled If IsMissing(ControlList) Then 'No paramarray has been supplied so enable/disable all of them For Each ctl In Me.Controls Select Case ctl.Name Case "controlname1", "controlname2" 'Leave these ones alone Case Else 'Enable/Disable these controls If ((Screen.ActiveControl.Name = ctl.Name) And (EnabledState = False)) Then 'Remember, you can't disable the control with the focus, so if the focus 'control is about to get disabled, set the focus to something else first. Me!somecontrol.SetFocus End If ctl.Enabled = EnabledState End Select Next ctl Else 'A paramarray has been supplied. Enable/disable only those controls For intIndex = LBound(ControlList) To UBound(ControlList) Set ctl = Me.Controls(ControlList(intIndex)) If ((Screen.ActiveControl.Name = ctl.Name) And (EnabledState = False)) Then 'Remember, you can't disable the control with the focus, so if the focus 'control is about to get disabled, set the focus to something else first. Me!somecontrol.SetFocus End If ctl.Enabled = EnabledState Next intIndex End If Set ctl = Nothing End Sub