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

OnKeyPress

Status
Not open for further replies.

lizI3

Programmer
Jul 2, 2002
31
0
0
CA
I'am having problems with toggle buttons in an option group. When you mousedown on an option toggle button it opens up another form. My problem is that I also wanted to be able to use a hotkey with it (alt + g as an example). I put the & sign in front of the letter G and it show the G with an underscore on the toggle button. When I press the G key the toggle button does press down but my code does not work. I put the same code from the mousedown event to the OnKeyPress event. This does not work
I am not sure how to code the onkeypress event. Can anyone help


thanks Liz





 
Liz:
Are there more than one options in your option group?
Why are you using the OnMouse Events for the Code. If this is a standard option group you should be using the On Click or After Update Event of the Option Group.

For example:
I have 3 forms I want to open. I have created an option group with 3 options, FORM1, FORM2 and FORM3. And have assigned the values 1, 2 and 3 to them.

I place the following in the On Click Event of the Frame (option Group)

Dim stDocName As String
Dim stLinkCriteria As String

Select Case Me.Frame0
Case is = 1
stDocName = "Form1"
Case is = 2
stDocName = "Form2"
Case is = 3
stDocName = "Form3"
End Select

DoCmd.OpenForm stDocName, , , stLinkCriteria

The above will open the specific Form have requested based on the Click or hot Key I assign.

HTH

Jeff


"I know what you're t'inkin', ma petite. Dat Gambit... still de suave one, no?"
 
Thanks Jfgambit that solved my problem, It work great now, but can you explain to me when you would use the mousedown or keypress or keydown events.

thanks again
Liz
 
Mouse move events are good for making changes to label or textbox Font, Boldness, BackGround, etc to enhance the look or to highlight key fields on a form. Hee's an example:

Private Sub Label0_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label0.FontBold = True
End Sub

KeyDown functions are good for calling running addition functionality stored behind the form. For Example,

' How to Detect the use of Ctrl + F2, F3, or F4'
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim intCtrlDown As Integer
intCtrlDown = (Shift And acCtrlMask) > 0
Select Case KeyCode
Case vbKeyF2
If intCtrlDown Then
MsgBox "You Pressed Ctrl+F2"
KeyCode = 0
End If
Case vbKeyF3
If intCtrlDown Then
MsgBox "You Pressed Ctrl+F3"
KeyCode = 0
End If
Case vbKeyF4
If intCtrlDown Then
MsgBox "You Pressed Ctrl+F4"
KeyCode = 0 End If
End Select
End Sub

HTH



"I know what you're t'inkin', ma petite. Dat Gambit... still de suave one, no?"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top