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

How to load form by pressing some key combination?

Status
Not open for further replies.

tb2007

Programmer
Apr 2, 2005
33
YU
I have one form from which I want to load some other secret form by pressing some key combination for instance:
CTRL ALT S

How to do this?

Secret form is used for some settings that user should not be able to see. I want to press CTRL ALT S and change some settings.

 
On the form you want to call the secret form from... set the KeyPreview = True

Then, in the key_up event, check for the CTRL ALT S combination, like this...

Code:
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
    
    If KeyCode = 83 And Shift = 6 Then
        [green]' call your secret form here[/green]
        Call MsgBox("Secret form here")
    End If
    
End Sub

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
By the way, Shift = 6 because of this:

6 in binary = 110

Ctrl Alt Shift
1 1 0

So, the Shift argument is 3 binary digits (where we get the term bit from) expressed as a decimal number.
 
And could have been written as:

If KeyCode = vbKeyS And Shift = vbCtrlMask + vbAltMask Then


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top