Use arrow key to move through records in a continuous form


/ Published in: Visual Basic
Save to your folder(s)

KeyPreview property must be set to Yes


Copy this code and paste it in your HTML
  1. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  2.  
  3. On Error GoTo ErrHandler
  4. Select Case KeyCode
  5. Case vbKeyDown
  6. DoCmd.GoToRecord Record:=acNext
  7. KeyCode = 0
  8. Case vbKeyUp
  9. DoCmd.GoToRecord Record:=acPrevious
  10. KeyCode = 0
  11. Case Else
  12. ' Do nothing
  13. End Select
  14.  
  15. Egress:
  16. Exit Sub
  17.  
  18. ErrHandler:
  19. If Err.Number = 2105 Then
  20. KeyCode = 0
  21. DoCmd.Beep
  22. Else
  23. MsgBox Err.Description
  24. End If
  25. Resume Egress
  26. End Sub

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.