T
Terry Holland
I have an unbound form that contains two subforms. One of these subforms is
a continuous form comprising rows of textboxes. What I need is to allow the
user to navigate around the textboxes as if they are cells in an excel
spreadsheet using the arrow keys.
ie left key moves focus to control the left on the on same row
right key moves focus to control the right on the on same row
up key moves focus to same control on the on the row above
down key moves focus to same control on the on the row below
Im using the following code but getting an error on the line
DoCmd.GoToRecord acDataForm, Me.Name, acPrevious
The error description is "Runtime error 2489: The object 'MySubForm' isn't
open"
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDown Then MoveDown
If KeyCode = vbKeyUp Then MoveUp
End Sub
Sub MoveDown()
Dim ctlFocus As Control
Set ctlFocus = Screen.ActiveControl '.Name
DoCmd.GoToRecord acDataForm, Me.Name, acNext
ctlFocus.SetFocus
End Sub
Sub MoveUp()
Dim ctlFocus As Control
Set ctlFocus = Screen.ActiveControl
DoCmd.GoToRecord acDataForm, Me.Name, acPrevious
ctlFocus.SetFocus
End Sub
a continuous form comprising rows of textboxes. What I need is to allow the
user to navigate around the textboxes as if they are cells in an excel
spreadsheet using the arrow keys.
ie left key moves focus to control the left on the on same row
right key moves focus to control the right on the on same row
up key moves focus to same control on the on the row above
down key moves focus to same control on the on the row below
Im using the following code but getting an error on the line
DoCmd.GoToRecord acDataForm, Me.Name, acPrevious
The error description is "Runtime error 2489: The object 'MySubForm' isn't
open"
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDown Then MoveDown
If KeyCode = vbKeyUp Then MoveUp
End Sub
Sub MoveDown()
Dim ctlFocus As Control
Set ctlFocus = Screen.ActiveControl '.Name
DoCmd.GoToRecord acDataForm, Me.Name, acNext
ctlFocus.SetFocus
End Sub
Sub MoveUp()
Dim ctlFocus As Control
Set ctlFocus = Screen.ActiveControl
DoCmd.GoToRecord acDataForm, Me.Name, acPrevious
ctlFocus.SetFocus
End Sub