down arrow key moves down, but it moves across to the right on continuse form


S

Song Su

I have a continuse form. When I hit down arrow key, it highlight moves
across to the right instead of same field next record. Is it possible to
move down when pressing down arrow and move up when pressing up arrow?
 
Ad

Advertisements

B

B. Edwards

Set the Key Preview property of the form to Yes

In the KeyDown event of the form place the following code:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
On Error GoTo Err_Label
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

Exit_Label:
Exit Sub
Err_Label:
If Err.Number = 2105 Then
KeyCode = 0
Else
MsgBox Err.Number
End If
Resume Exit_Label
End Sub
 
Ad

Advertisements

S

Song Su

Thanks a lot. It works great!

B. Edwards said:
Set the Key Preview property of the form to Yes

In the KeyDown event of the form place the following code:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
On Error GoTo Err_Label
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

Exit_Label:
Exit Sub
Err_Label:
If Err.Number = 2105 Then
KeyCode = 0
Else
MsgBox Err.Number
End If
Resume Exit_Label
End Sub
 

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