[AccessD] Shift+F2 using code

MartyConnelly martyconnelly at shaw.ca
Sat Dec 13 17:29:32 CST 2003


On your form set focus to textbox and call snapzoom routine

Private Sub Command9_Click()
Me.Text7.SetFocus
SnapZoom
End Sub

In a module

Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte,ByVal _
 bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

public Sub SnapZoom()
'use the following code inside form or focused window or text box
'to simulate the F2/Shift = key combination:

     ' then press and then release the F2 Shift key
     'order of pressing important
     keybd_event vbKeyShift, 0, 0, 0
      keybd_event vbKeyF2, 0, 0, 0
     
      
    keybd_event vbKeyF2, 0, KEYEVENTF_KEYUP, 0
    'weird things happen if you don't up the shiftkey; looks like capslock
    keybd_event vbKeyShift, 0, KEYEVENTF_KEYUP, 0
 
  DoEvents
 
End Sub

Barbara Ryan wrote:

>Is there a way to programatically (i.e., in VBA) to execute a Shift+F2 (in order to "Zoom in" on a field on a form) without using Sendkeys?
>
>Thanks,
>Barb Ryan
>
>  
>

-- 
Marty Connelly
Victoria, B.C.
Canada





More information about the AccessD mailing list