I am about to pull my hair out! I have a form and everything is working great on it except one thing, the textbox.setfocus. I’ve searched for solutions and I’ve tried all sorts of things. I read it has to be enabled and it has to be visible so I made sure my textbox was visible and enabled. Below is my code.
It errors on line 12 with an Error #5 Invalid Procedure Call or Argument. What also bugs me is the error doesn’t happen all the time, just sometimes and it is only happening when it is compiled. Does anyone have any suggestions?
Code:
Private Sub Clear()
On Error GoTo ErrorHandler
2 txtGO.Text = ""
3 txtYard.Text = ""
4 txtDesc.Text = ""
5 txtAmount.Text = ""
6 chkApprove.Value = 0
7 txtTotal.Text = ""
8 chkApprove.Value = 0
9 If txtGO.Visible = False Or txtGO.Enabled = False Then
10 txtGO.Visible = True
11 txtGO.Enabled = True
12 txtGO.SetFocus
13 Else
14 txtGO.SetFocus
15 End If
ErrorHandler:
If Err.Number <> 0 Then
MsgBox "Error # " & Err.Number & "on line # " & Erl
End If
End Sub
It errors on line 12 with an Error #5 Invalid Procedure Call or Argument. What also bugs me is the error doesn’t happen all the time, just sometimes and it is only happening when it is compiled. Does anyone have any suggestions?