Disable PAGE UP and PAGE DOWN keys in a form

By default, the PAGE UP and PAGE DOWN keys can be used to navigate between records in a form. The followng example illustrates how to use a form's KeyDown event to disable the use of the PAGE UP and PAGE DOWN keys in the form.

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) 
 
    ' The Keycode value represents the key that 
    ' triggered the event. 
    Select Case KeyCode 
    
        ' Check for the PAGE UP and PAGE DOWN keys. 
        Case 33, 34 
 
        ' Cancel the keystroke. 
        KeyCode = 0 
    End Select 
End Sub

Note

You must set the form's KeyPreview property to True for this procedure to work.