NoePa,
I guess that owuld explain it....
I guess that owuld explain it....
Private Sub Form_Open(Cancel As Integer)
SendKeys "%{F5}"
End Sub
Private Sub Form_Open(Cancel As Integer)
Call SendKeys("%{F5}{TAB}{TAB}{TAB}{TAB}")
End Sub
Option Compare Database
Option Explicit
Public Declare Sub keybd_event Lib "user32" ( _
ByVal bVk As Byte, _
ByVal bScan As Byte, _
ByVal dwFlags As Long, _
ByVal dwExtraInfo As Long)
Declare Function GetKeyState Lib "user32.dll" ( _
ByVal nVirtKey As Long) As Integer
Private Const vk_Tab = &H9 'TAB key
Private Const vk_Alt = &H12 'Alt key
Private Const vk_F5 = &H74 'F5 Key
Private Const vk_KEYUP = &H2 'indicates the key being released
Public Function vkTab()
keybd_event vk_Tab, 1, 0, 0
End Function
Public Function vkTabUp()
keybd_event vk_Tab, 1, vk_KEYUP, 0
End Function
Public Function vkAlt()
keybd_event vk_Alt, 1, 0, 0
End Function
Public Function vkAltUp()
keybd_event vk_Alt, 1, vk_KEYUP, 0
End Function
Public Function vkF5()
keybd_event vk_F5, 1, 0, 0
End Function
Public Function vkF5Up()
keybd_event vk_F5, 1, vk_KEYUP, 0
End Function
Private Sub cmdGoToSearch_Click()
Call vkAlt
Call vkF5
Call vkF5Up
Call vkF5Up
Call vkAltUp
Call vkTab
Call vkTabUp
Call vkTab
Call vkTabUp
Call vkTab
Call vkTabUp
Call vkTab
Call vkTabUp
Call vkTab
Call vkTabUp
End Sub
Tab in there, because my Access also has a "Filter" control that must be skipped over. Keep in mind that you may have to check to see if you are at a new record, because you will need fewer Tab characters if you are.SendKeys(), or any code that relies on the state of something. That said, there are times when it can do what's required. In this case, I would expect that the requirement for being run in the Form_Open() event procedure would/should make its behaviour fairly predictable. It would also have the advantage of being understandable (if somewhat obscure) and readable in one go.
Comment