Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disabling Page Up/Page Down Keys for Record Navigation 1

Status
Not open for further replies.

burritonator

IS-IT--Management
Jun 15, 2004
133
US
I have found several posts dealing with the issue of how to diable the mouse wheel so that it will not allow record navigation on bound Access forms. There are several solutions suggested that I am going to try.

However, an issue that I have been unable to find much information about is how to also disbale certain keyboard keys, such as Page Up and Page Down, from allowing navigation through the records. The only solution to that issue that I found on this messageboard came with a caution that it effectively disables the "Me.Dirty" feature, which I make use of on my forms, so that solution isn't an option for me.

Does anyone have any suggestions as to how I could disable the keyboard keys from allowing record navigation? I suppose a simpler way to state my goal is that I don't want for the user to be able to navigate through the records via any methods other than the controls that I provide on the forms for doing so.

Thanks,
Burrito
 
Set the Form's KeyPreview Event to True
Use the Form's KeyDown Event to check for the keys, and then reset the KeyCode to Zero.


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

PaulF
 
Hi Paul,

I was hoping you could assist me with your code.

I have implemented the above code, adding a check for vbKeyHome and vbKeyEnd

I have a PageBreak Control on a form.
I fiqured out how to turn KeyPreView off so that the code works, but how can I re-enable it.

Here's the code I'm trying to make work.
If I add back the commented out code, then the SendKeys event fails.

Code:
Select Case Me.lblAddPhotos.Caption
  Case "&Go Back"
    Me.lblAddPhotos.Caption = "Add &Photo(s)"
    Forms!frmAddNewSugg.KeyPreview = False
      SendKeys "{PGUP}", False
'    Forms!frmAddNewSugg.KeyPreview = True
  Case "Add &Photo(s)"
    Me.lblAddPhotos.Caption = "&Go Back"
    Forms!frmAddNewSugg.KeyPreview = False
      SendKeys "{PGDN}", False
    'Forms!frmAddNewSugg.KeyPreview = True
  Case Else 'do nothing
End Select

I've tried adding Forms!frmAddNewSugg.KeyPreview = True
just before the exit sub, and it failed also!
Now, unfortunately, the Home - End - PageUp - PageDown keys are active again.
Any solutions...

Thanks

AccessGuruCarl
Programmers helping programmers
you can't find a better site.
 
Have you tried something like this ?
Select Case Me.lblAddPhotos.Caption
Case "&Go Back"
Me.lblAddPhotos.Caption = "Add &Photo(s)"
Forms!frmAddNewSugg.SetFocus
DoCmd.GoToRecord acDataForm, "frmAddNewSugg", acPrevious
Case "Add &Photo(s)"
Me.lblAddPhotos.Caption = "&Go Back"
Forms!frmAddNewSugg.SetFocus
DoCmd.GoToRecord acDataForm, "frmAddNewSugg", acNext ' or acNewRec perhaps ?
Case Else 'do nothing
End Select

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks for the suggestion PHV,

Let me explain in more detail.
The Add New Suggestion Form.
When Displayed is about 5" wide x 4" tall.

In Design View it's 5" x 12" with a PageBreak Control every 4"

When the user completes the data in the first 4" of the form, (first pagebreak), they move to the next pagebreak.

Paul's code works great, but it won't re-enable the key preview to true? Seems like there must be something I can do to enable this?
I've tried Form.Refresh, Form.Repaint, Form.Requery

Any idea's or suggestions?

Thanks....

AccessGuruCarl
Programmers helping programmers
you can't find a better site.
 
Why not simply use the GoToPage method of the Form object or the SetFocus method ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV

Didn't know what control to use!

As I'm sure your aware already from the # of responses you've answered for me, I don't actively program.

I know what I want, when I want it, It's just figuring out what I need to get to work! Someday I'll actually get a chance to LEARN what I'm really doing! Maybe when I retire, LOL....

Thanks Again!
Another Star.....

AccessGuruCarl
Programmers helping programmers
you can't find a better site.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top