pullingteeth
Programmer
Hello, the following code (written in a macro language which can call out to the win32 API) switches from the user's window to an Access window ("tracking"), and activates a form with the "f5" key. In theory. It all works apart from the "f5" key, which doesn't seem to be accepted by the Access window; however, if I press "f5" myself after the macro has finished, it works (i.e. the window is at the front, has focus, and appears to be active). So where's the problem? Thanks in advance.
Code:
dim ntsid as long
dim y as long, tdbid as long
' get the NTS id
ntsid = GetForegroundWindow
' get the
tdbid = FindWindow("", "Tracking")
if tdbid = 0 then
msgbox "You haven't opened the database yet! Please do so now, login, " _
& "and then click OK..."
tdbid = FindWindow("", "Tracking")
if tdbid = 0 then
msgbox "Sorry, I still can't find the database. Your action won't " _
& "be recorded. Run the macro again if you like."
goto endAndLetThemFigureItOut
end if
else
' Close (minimize, deactivate) the nts window
y = CloseWindow(ntsid)
end if
' Maximize the tracking db window
y = ShowWindow(tdbid, 1)
' Bring it to the foreground so it can accept input
y = SetForegroundWindow(tdbid)
' Update it, so it displays itself at the front
y = UpdateWindow(tdbid)
'**********************************************************************************
'INPUT TO DB
' Pause for one second , so the users can see a message of the day if
' there is one, etc
pause 1
sendkeys "{f5}"