Dim ctl as Control
For Each ctl in Me.Controls
If ctl.ControlType = acTextbox
ctl.Enabled = True
End if
ctl.Enabled = Not ctl.Enabled
Private Sub btnAllowEdit_Click()
'Actions
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
ctl.Enabled = True
End If
Next ctl
'Buttons
Me.btnStopEdit.Visible = True
Me.EmployeeNumber.SetFocus
Me.btnAllowEdit.Visible = False
End Sub
Private Sub btnStopEdit_Click()
'Actions
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
ctl.Enabled = Not ctl.Enabled
End If
Next ctl
'Buttons
Me.btnStopEdit.Visible = False
Me.EmployeeNumber.SetFocus
Me.btnAllowEdit.Visible = True
End Sub
When I hit the btnAllowEdit button, every textbox becomes enabled and the buttons switch (the SetFocus part is becouse focused buttons can't be hidden) but when I hit the btnStopEdit button... nothing happens. The buttons don't even change... why?I'm using (second) mbizup's approach as I need to see the disabled fieldsI'm not following what you mean here. All the solutions posted will not hide the fields but just dIsable them. Can you explain a bit more?
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox OR ctl.ControlType = acAttachment Then
ctl.Enabled = Not ctl.Enabled
End If
Next ctl
Open in new window