Page Down Key Action

B

B F Cole

I have a form that is larger than one screen vertically.. The user can
scroll down or press the Page Down key to get to the bottom. If the user
presses Page Down twice, the form goes to a new blank record which I want to
prevent. I know how to disable the Page up & Page Down keys, how to count
the number of times the key has been pressed, etc, but how do I prevent Page
Down on a form from going to a new blank record? There should be a
parameter that controls this action or locks the form to the current record
only. I haven't found it. Any suggestions?

Thanks,
Bill
 
M

missinglinq via AccessMonster.com

While Help only refers to it in relationship to the TAB key, I think the
form's Cycle Property will handle this as well. Goto your form's Properties
Box > Other > Cycle and set to Current Record.

Good Luck!
 
D

Damon Heron

Put this code on the form, and set the form's Cycle property to
currentrecord. You may have to experiment with the count numbers for your
particular form, or adjust the length of the form somewhat. The ct is a
variable that is global for the form.

Private Sub Form_Current()
ct = 1
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
'33 - PgUp; 34 - PgDown;
Select Case KeyCode
Case 33
ct = ct - 1
If ct <= 1 Then
KeyCode = 0
ct = 1
End If
Case 34
ct = ct + 1
If ct > 2 Then
KeyCode = 0
ct = 3
End If
Case Else

End Select
End Sub

Private Sub Form_Load()
Me.KeyPreview = True
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top