virusworld
Programmer
- Nov 28, 2024
- 1
suppose you have a btn1 on form
and you want to use this button in multiple ways so if shift key is pressed and you click on that button it will open form2 else open form1
to do That :
1- Enable Key Preview in Form
2- declare An integer to the form ( dim ShiftPressed as Integer)
3 - Add Form_KeyDown event:
[/CODE]
4 - Add Form_KeyUp event :
[/CODE]
5 - Btn1 Click Event:
and you want to use this button in multiple ways so if shift key is pressed and you click on that button it will open form2 else open form1
to do That :
1- Enable Key Preview in Form
2- declare An integer to the form ( dim ShiftPressed as Integer)
3 - Add Form_KeyDown event:
Code:
[CODE]Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyShift Then
ShiftPressed= 1 End If
End Sub
4 - Add Form_KeyUp event :
Code:
[CODE]Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyShift Then
ShiftPressed= 0 End If
End Sub
5 - Btn1 Click Event:
Code:
btn1_Click()
if ShiftPressed = 0 then
docmd.openForm "form1"
else
docmd.openForm "form2"
end if