Disable PageUp and PageDown Keys

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

when doing a: DoCmd.GoToRecord , , acNewRec

and pressing the page up/down buttons the form jumps to the next record.

any idea on how to force a form to stay within the current data record ?

henry
 
You can set the form's KeyPreview to Yes, and then use the KeyDown event to
trap the PageUp/PageDown keystrokes and destroy them by settting KeyCode to
zero.

The more important question is what you are trying to do here. If you are
trying to ensure that the record is filled out completely before the user
moves to another record, use the BeforeUpdate event of the form to perform
the record validation. Access fires that event regardless of why the record
is being saved, e.g. the user scrolled the mouse, pressed Shift+Enter,
closed the form, chose Save Record from the Records menu, closed Access,
and so on.

This example shows how to use the event:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me.Surname) Then
Cancel = True
MsgBox "Enter a surname."
End If
End Sub
 
any idea on how to force a form to stay within the current data record ?

If I really want the user to work with one record at a time, I only give
them one in the Form.Recordsource:

SELECT * FROM SomeTable WHERE PKValue=1038

The Cycle property can also limit the user to one page or record or not,
but I don't know how that affects the PgUp/ PgDn keys.

Hope that helps


Tim F
 
Back
Top