Keyboard handlers

  • Thread starter Thread starter roger
  • Start date Start date
R

roger

I wanted to know what would I do if I want to write code
such that if the user presses the pageup and pagedown
buttons on the keyboard nothing would happen.
PLease advise
 
Hi Roger,

You can use the KeyDown event of the form -just be sure to also set the
KeyPreview property of the form to yes (under the events tab).

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyPageDown Or KeyCode = vbKeyPageUp Then
KeyCode = 0
'MsgBox "blocked"
End If
End Sub
 
Thankyou very much Sandra. That worked out just fine for
me.

Now this would work for both the page up and page down
keys andas well as the pgup and pgdn keys right?
-----Original Message-----
Hi Roger,

You can use the KeyDown event of the form -just be sure to also set the
KeyPreview property of the form to yes (under the events tab).

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyPageDown Or KeyCode = vbKeyPageUp Then
KeyCode = 0
'MsgBox "blocked"
End If
End Sub


--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

I wanted to know what would I do if I want to write code
such that if the user presses the pageup and pagedown
buttons on the keyboard nothing would happen.
PLease advise

.
 
Yes, it does appear to block PgUp and PgDn as well. I had to think for a
minute about what you meant since I always have Numlock on :-)

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Thankyou very much Sandra. That worked out just fine for
me.

Now this would work for both the page up and page down
keys andas well as the pgup and pgdn keys right?
-----Original Message-----
Hi Roger,

You can use the KeyDown event of the form -just be sure to also set
the KeyPreview property of the form to yes (under the events tab).

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyPageDown Or KeyCode = vbKeyPageUp Then
KeyCode = 0
'MsgBox "blocked"
End If
End Sub


--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

I wanted to know what would I do if I want to write code
such that if the user presses the pageup and pagedown
buttons on the keyboard nothing would happen.
PLease advise

.
 
Back
Top