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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disallowing keyboard navigation in forms 1

Status
Not open for further replies.

xhonzi

Programmer
Jul 29, 2003
196
US
Where is the setting that disables keys like PGUP, Home, etc..?

I have listboxes that control navigation in my form and I'd like other keyboard based navigation disabled.

xhonzi
 
Howdy xhonzi . . .

The only setting that disables keys are in the StartUp menu, and they don't involve form navigation. Gotta drum up some code for this one. So in form design view perform the following:
[ol][li]Call up the [blue]properties[/blue] window.[/li]
[li]Set the forms [blue]Key Preview[/blue] event to [blue]Yes[/blue].[/li]
[li]In the [blue]forms code module[/blue] copy/paste the following:
Code:
[blue]Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
   
   Select Case KeyCode
      Case 9, 13, 33 To 40
         KeyCode = 0 [green]'disable key and/or combination[/green]
   End Select
   
   [green]'KeyCode KeyName
   '***************
   '09      Tab
   '13      Enter
   '38      Up Arrow
   '40      Down Arrow
   '39      Right Arrow
   '37      Left Arrow
   '33      Page Up
   '34      Page Down
   '36      Home
   '35      End[/green]
   
End Sub[/blue]
[/li][/ol]
You can add/remove keys as you wish, just be sure to get the [blue]Case Statement[/blue] correct.

Thats it! . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top