Use of Arrow Keys in Continuous form View

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.
 
R

Rick Brandt

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
 
C

Chaplain Doug

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?
 
A

Albert D. Kallal

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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top