P
Pastor Del
I found this code (EnableFormControls) in the forum to enable/disable
controls on a form but I'm having trouble setting the variable 'frmAny' and
passing it to the sub EnableFormControls. What am I doing wrong?
Sub EnableFormControls(frmAny As Form, _
strControlSkip As String, _
Optional tfEnable As Boolean = True)
Dim ctlAny As Control
On Error GoTo ERROR_Handler
frmAny(strControlSkip).SetFocus
For Each ctlAny In frmAny.Controls
If ctlAny.Name <> strControlSkip Then
Select Case ctlAny.ControlType
Case acCheckBox, acComboBox, acCommandButton _
, acListBox, acOptionGroup, acSubform _
, acTextBox, acToggleButton
ctlAny.Enabled = tfEnable
End Select
End If
Next ctlAny
Exit Sub
ERROR_Handler:
If Err.Number = 2164 Then
Resume Next
Else
MsgBox Err.Number & ": " & Err.Description, , _
"Error in EnableFormControls"
End If
End Sub
Private Sub Command1_Click()
Dim frmAny As Form
Dim strControlSkip As String
Dim tfEnable As Boolean
frmAny = Form2
strControlSkip = "Text2"
tfEnable = False
EnableFormControls frmAny, strControlSkip, tfEnable
End Sub
controls on a form but I'm having trouble setting the variable 'frmAny' and
passing it to the sub EnableFormControls. What am I doing wrong?
Sub EnableFormControls(frmAny As Form, _
strControlSkip As String, _
Optional tfEnable As Boolean = True)
Dim ctlAny As Control
On Error GoTo ERROR_Handler
frmAny(strControlSkip).SetFocus
For Each ctlAny In frmAny.Controls
If ctlAny.Name <> strControlSkip Then
Select Case ctlAny.ControlType
Case acCheckBox, acComboBox, acCommandButton _
, acListBox, acOptionGroup, acSubform _
, acTextBox, acToggleButton
ctlAny.Enabled = tfEnable
End Select
End If
Next ctlAny
Exit Sub
ERROR_Handler:
If Err.Number = 2164 Then
Resume Next
Else
MsgBox Err.Number & ": " & Err.Description, , _
"Error in EnableFormControls"
End If
End Sub
Private Sub Command1_Click()
Dim frmAny As Form
Dim strControlSkip As String
Dim tfEnable As Boolean
frmAny = Form2
strControlSkip = "Text2"
tfEnable = False
EnableFormControls frmAny, strControlSkip, tfEnable
End Sub