Posted By

heislekw on 12/31/10


Tagged

form continuous


Versions (?)

Use arrow key to move through records in a continuous form


 / Published in: Visual Basic
 

KeyPreview property must be set to Yes

  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  

You need to login to post a comment.