After some searching, found code that can keep the Access window on top. I'm using this because when I run code to send reports to PDF, acrobat window comes on top and the focus doesn't get set back to Access, so without clicking on the access window occasionally, I can't tell when the code has completed, even though I have a message box to say it has finished. Since the code was cobbled together from three sources, and don't really know about API's can't say for sure if I implemented it right other than it seems to work for my purpose. The code came from mostly from Microsoft and a piece from xtremevbtalk.
Put the following in a code module:
Then in your code call the Float before the point you want to keep Access on top and UnFloat after that has been done so that window functionality is restored, otherwise Access will remain on top from then on, which could be problematic for doing non access stuff.
Put the following in a code module:
Code:
'Found NoTopMost, which undoes the Window on Top from [URL unfurl="true"]http://www.xtremevbtalk.com/archive/index.php/t-94578.html[/URL]
'[URL unfurl="true"]http://support.microsoft.com/kb/210500[/URL]
' 1. Add the following API declarations to your Global Declarations section:
Declare Function FindWindow% Lib "user32" Alias "FindWindowA" _
(ByVal lpClassname As Any, _
ByVal lpCaption As Any)
Declare Function SetWindowPos Lib "user32" (ByVal Hwnd As Long, _
ByVal hWndInsertAfter As Long, _
ByVal X As Long, _
ByVal y As Long, _
ByVal cx As Long, _
ByVal cy As Long, _
ByVal wFlags As Long) As Long
' 2. Add the following Constants to your Global Declarations section:
Global Const HWND_TOPMOST = -1
Global Const HWND_NOTOPMOST = -2
Global Const SWP_NOSIZE = &H1
Global Const SWP_NOMOVE = &H2
' 3. Type the following function:
Function Float_Main()
Dim X&, Hwnd%
' X = Shell("CALC.EXE", 1)
Hwnd% = FindWindow%("omain", 0&)
Call SetWindowPos(Hwnd%, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or _
SWP_NOSIZE)
End Function
Function UnFloat_Main()
Dim X&, Hwnd%
' X = Shell("CALC.EXE", 1)
Hwnd% = FindWindow%("omain", 0&)
Call SetWindowPos(Hwnd%, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or _
SWP_NOSIZE)
End Function
Then in your code call the Float before the point you want to keep Access on top and UnFloat after that has been done so that window functionality is restored, otherwise Access will remain on top from then on, which could be problematic for doing non access stuff.