I have been using the following code to cycle through a subform and disable all textboxes on a form. If a textbox on the form has the focus when this is run I get error "can't disable a control when it has the focus." When I add a line like "txtTest.SetFoc us" where txtTest is a textbox on the main form I still get the same error. How do I resolve this issue? Also, please note that I disable all controls on the subform.
thank you for your time
Code:
Private Sub EnableControls(ByRef frm As Form, ByRef CtrlTypeName As String, Enable As Boolean) Dim nCount As Integer For nCount = 0 To frm.Controls.Count - 1 If TypeName(frm.Controls(nCount)) = CtrlTypeName Then frm.Controls(nCount).Enabled = Enable End If Next End Sub
Comment