jardenp
Active Member
- Joined
- May 12, 2009
- Messages
- 373
- Office Version
- 2019
- 2016
- 2013
- 2011
- 2010
- Platform
- Windows
I would like to set the focus on the CheckTrip_CB1 command button text box MilesPaid_TB1 is empty to avoid the user having to tab through about 10 fields that are irrelevant because that certain condition is met.
When I run this code, I get runtime error '-2147467259 (80004005)' unspecified and clicking debug takes me to the .SetFocus line.
I've read through 25-30 posts on how to get .SetFocus to work here and I can't make sense of it. I've seen multiple "workaround" solutions but none work for me.
Everything in the sub EndOdomExit works fine. Everything works fine unless I try to set the focus in the exit event sub.
When I put a debug.print or msgbox immediately above the .SetFocus line, it seems it's running through the code a couple times before hitting the error.
Has anyone figured run into this issue and found a satisfactory answer? Thanks!
When I run this code, I get runtime error '-2147467259 (80004005)' unspecified and clicking debug takes me to the .SetFocus line.
VBA Code:
Private Sub EndOdom_TB1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Entry = 1
ExitAllSubs = False
EndOdomExit
Entry = 0
If Me.MilesPaid_TB1 = "" Then
Me.CheckTrip_CB1.SetFocus
End If
Cancel = True
End Sub
Everything in the sub EndOdomExit works fine. Everything works fine unless I try to set the focus in the exit event sub.
When I put a debug.print or msgbox immediately above the .SetFocus line, it seems it's running through the code a couple times before hitting the error.
Has anyone figured run into this issue and found a satisfactory answer? Thanks!