Use of Arrow Keys in Continuous form View

  • Thread starter Thread starter Chaplain Doug
  • Start date Start date
C

Chaplain Doug

Access 2002. I am displaying three columns (fields) of
data in a continuous form. How can I make the arrow key
(up or down) move me to the next or previous record in the
same field? This works in datasheet view, but not in
continuous form view. Thanks.
 
Chaplain Doug said:
Access 2002. I am displaying three columns (fields) of
data in a continuous form. How can I make the arrow key
(up or down) move me to the next or previous record in the
same field? This works in datasheet view, but not in
continuous form view. Thanks.

I use the following in the form's KeyDown event

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

On Error GoTo ErrHandler
Select Case KeyCode
Case vbKeyDown
DoCmd.GoToRecord Record:=acNext
KeyCode = 0
Case vbKeyUp
DoCmd.GoToRecord Record:=acPrevious
KeyCode = 0
Case Else
' Do nothing
End Select

Egress:
Exit Sub

ErrHandler:
If Err.Number = 2105 Then
KeyCode = 0
DoCmd.Beep
Else
MsgBox Err.Description
End If
Resume Egress
End Sub
 
I put this code in my form. However, what happens is that
if I am in field 2 of 3 when I press the down arrow key,
rather than going to field 2 of the next record, it tabs
to field 3 of the same record. If I press the down arrow
in field 3 (the last field), then it goes to the next
record field 2. What do I need to fix here?
 
You need to set the forms "keyPreview" to yes.

Also, make sure you have the keydown event set. (use the [...] thingy to
create this event else it may not fire...
 
Back
Top