Open Form (1 Viewer)

davey3389

Registered User.
Local time
Today, 23:05
Joined
Jul 16, 2012
Messages
30
Can anyone tell me if there is a code i can enter than when i press F9 on the keyboard it opens a form
 

John Big Booty

AWF VIP
Local time
Tomorrow, 08:05
Joined
Aug 29, 2005
Messages
8,262
You can use the KeyDown event to detect a key press, some code in that event along the lines of;
Code:
If KeyCode = 120 Then
     DoCmd.[URL="http://msdn.microsoft.com/en-us/library/office/aa220276%28v=office.11%29.aspx"]OpenForm[/URL] "YourFormName"
End If
 

davey3389

Registered User.
Local time
Today, 23:05
Joined
Jul 16, 2012
Messages
30
Thanks can you explain why F9 is key code 120
 

John Big Booty

AWF VIP
Local time
Tomorrow, 08:05
Joined
Aug 29, 2005
Messages
8,262
If you want to find out the value of a key use;
Code:
MsgBox KeyCode
In the Key Down event.
 

davey3389

Registered User.
Local time
Today, 23:05
Joined
Jul 16, 2012
Messages
30
Where do i enter the code so it works from any part of the database
 

John Big Booty

AWF VIP
Local time
Tomorrow, 08:05
Joined
Aug 29, 2005
Messages
8,262
The Key Down event is specific to forms. So you will need at least one form open for this code to work.
 

bob fitz

AWF VIP
Local time
Today, 23:05
Joined
May 23, 2011
Messages
4,730
In the Key Down event of a form, as John said in his earlier post. If the form has any controls, I think you will need to set the forms Key Preview property to Yes.

Sorry John, I got distracted and missed your last post.
 

John Big Booty

AWF VIP
Local time
Tomorrow, 08:05
Joined
Aug 29, 2005
Messages
8,262
No problem bob, you've added a little move info that I had not thought to mention :)
 

davey3389

Registered User.
Local time
Today, 23:05
Joined
Jul 16, 2012
Messages
30
so i can enter the code in one form to open another form
 

John Big Booty

AWF VIP
Local time
Tomorrow, 08:05
Joined
Aug 29, 2005
Messages
8,262
You'd need;
Code:
If KeyCode = 120 Then
     DoCmd.RunMacro "YourMacroName"
End If
 

Users who are viewing this thread

Top Bottom