SyntaxSocialist
Registered User.
- Local time
- Today, 00:31
- Joined
- Apr 18, 2013
- Messages
- 109
On a form (default view: Single), I have a bunch of bound controls that display one record at a time from tblMain. I have a bunch of unbound controls as well (buttons).
If the user tabs through all the controls, reaches the last one (btnLast), and presses tab again, the focus is set to the first control (btnFirst) and the bound controls change to display the next record. I just want the focus to be set to the first control without the displayed record being changed.
So I set up an "If" statement in Private Sub btnFirst_GotFocus()
But btnFirst gets the focus when the form opens, so Screen.PreviousControl spits out an error.
I've accommodated this like so:
Is this just bad practice? I'm sure many of you have lots of ideas on how I can accomplish this better. My application is a bit idiosyncratic, though, so I'm not sure if all of them will work.
Only one way to find out!
If the user tabs through all the controls, reaches the last one (btnLast), and presses tab again, the focus is set to the first control (btnFirst) and the bound controls change to display the next record. I just want the focus to be set to the first control without the displayed record being changed.
So I set up an "If" statement in Private Sub btnFirst_GotFocus()
Code:
If Screen.PreviousControl.Name = "btnLast" Then
[code to change record back to previous record]
End If
But btnFirst gets the focus when the form opens, so Screen.PreviousControl spits out an error.
I've accommodated this like so:
Code:
On Error GoTo ErrorHandler
If Screen.PreviousControl.Name = "btnLast" Then
[code to change record back to previous record]
End If
Exit Sub
ErrorHandler:
Exit Sub
Is this just bad practice? I'm sure many of you have lots of ideas on how I can accomplish this better. My application is a bit idiosyncratic, though, so I'm not sure if all of them will work.
Only one way to find out!