<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1106" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV>William -</DIV>
<DIV> </DIV>
<DIV>Quick question - you said:</DIV>
<DIV><FONT face=Arial size=2> "...works like a charm in all
versions ...HTH :))))"</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV>Does that apply to Windows versions as well? This is an Access97
runtime application (installed with Sagekey scripts), that is running on
everything from Windows95 up. Thanks.</DIV>
<DIV> </DIV>
<DIV>Best Regards,</DIV>
<DIV> </DIV>
<DIV>Julie Schwalm<BR>Backroads Data<BR><A
href="http://www.backroadsdata.com">www.backroadsdata.com</A><BR>785-594-6807</DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=wdhindman@bellsouth.net href="mailto:wdhindman@bellsouth.net">William
Hindman</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=accessd@databaseadvisors.com
href="mailto:accessd@databaseadvisors.com">Access Developers discussion and
problem solving</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Tuesday, September 09, 2003 12:06
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [AccessD] Automation between
2 applications</DIV>
<DIV><BR></DIV>
<DIV><FONT face=Arial size=2>Julie</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>...I've used the following code since A97 in my
Autoexec macro to handle multiple instances of my Access apps being opened by
users ...it should meet all of your stated needs ...just modify the IfThen to
call your process.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>...copy and insert the following module as
mdlCheckMultipleInstances</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Option Compare Database<BR>Option
Explicit</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>' Module mdlCheckMultipleInstances<BR>' © Graham
Mandeno, Alpha Solutions, Auckland, NZ<BR>' <A
href="mailto:graham@alpha.co.nz">graham@alpha.co.nz</A><BR> <BR>Private
Const cMaxBuffer = 255<BR> <BR>Private Declare Function apiGetClassName
Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As
String, ByVal nMaxCount As Long) As Long<BR> <BR>Private
Declare Function apiGetDesktopWindow Lib "user32" _<BR> Alias
"GetDesktopWindow" _<BR> () As Long<BR> <BR>Private Declare
Function apiGetWindow Lib "user32" _<BR> Alias "GetWindow" _<BR>
(ByVal hwnd As Long, _<BR> ByVal wCmd As Long) _<BR> As
Long<BR> <BR>Private Const GW_CHILD = 5<BR>Private Const GW_HWNDNEXT =
2<BR> <BR>Private Declare Function apiGetWindowText Lib "user32"
_<BR> Alias "GetWindowTextA" _<BR> (ByVal hwnd As Long,
_<BR> ByVal lpString As String, _<BR> ByVal aint As Long)
_<BR> As Long<BR> <BR>Private Declare Function apiSetActiveWindow
Lib "user32" _<BR> Alias "SetActiveWindow" _<BR> (ByVal hwnd As
Long) _<BR> As Long<BR> <BR>Private Declare Function apiIsIconic
Lib "user32" _<BR> Alias "IsIconic" _<BR> (ByVal hwnd As Long)
_<BR> As Long<BR> <BR>Private Declare Function apiShowWindowAsync
Lib "user32" _<BR> Alias "ShowWindowAsync" _<BR> (ByVal hwnd As
Long, _<BR> ByVal nCmdShow As Long) _<BR> As
Long<BR> <BR>Private Const SW_SHOW = 5<BR>Private Const SW_RESTORE =
9</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>Public Function winGetClassName(hwnd As Long) As
String<BR>Dim sBuffer As String, iLen As Integer<BR> sBuffer =
String$(cMaxBuffer - 1, 0)<BR> iLen = apiGetClassName(hwnd, sBuffer,
cMaxBuffer)<BR> If iLen > 0 Then<BR>
winGetClassName = Left$(sBuffer, iLen)<BR> End If<BR>End
Function<BR> <BR>Public Function winGetTitle(hwnd As Long) As
String<BR>Dim sBuffer As String, iLen As Integer<BR> sBuffer =
String$(cMaxBuffer - 1, 0)<BR> iLen = apiGetWindowText(hwnd, sBuffer,
cMaxBuffer)<BR> If iLen > 0 Then<BR> winGetTitle =
Left$(sBuffer, iLen)<BR> End If<BR>End Function<BR> <BR>Public
Function winGetHWndDB(Optional hWndApp As Long) As Long<BR>Dim hwnd As
Long<BR>winGetHWndDB = 0<BR>If hWndApp <> 0 Then<BR> If
winGetClassName(hWndApp) <> "OMain" Then Exit Function<BR>End If<BR>hwnd
= winGetHWndMDI(hWndApp)<BR>If hwnd = 0 Then Exit Function<BR>hwnd =
apiGetWindow(hwnd, GW_CHILD)<BR>Do Until hwnd = 0<BR> If
winGetClassName(hwnd) = "ODb" Then<BR> winGetHWndDB =
hwnd<BR> Exit Do<BR> End If<BR> hwnd =
apiGetWindow(hwnd, GW_HWNDNEXT)<BR>Loop<BR>End Function<BR> <BR>Public
Function winGetHWndMDI(Optional hWndApp As Long) As Long<BR>Dim hwnd As
Long<BR>winGetHWndMDI = 0<BR>If hWndApp = 0 Then hWndApp =
Application.hWndAccessApp<BR>hwnd = apiGetWindow(hWndApp, GW_CHILD)<BR>Do
Until hwnd = 0<BR> If winGetClassName(hwnd) = "MDIClient"
Then<BR> winGetHWndMDI = hwnd<BR> Exit
Do<BR> End If<BR> hwnd = apiGetWindow(hwnd,
GW_HWNDNEXT)<BR>Loop<BR>End Function<BR> <BR>Public Function
winCheckMultipleInstances(Optional fConfirm As Boolean = True) As
Boolean<BR>Dim fSwitch As Boolean, sMyCaption As String<BR>Dim hWndApp As
Long, hWndDb As Long<BR>On Error GoTo ProcErr<BR> sMyCaption =
winGetTitle(winGetHWndDB())<BR> hWndApp =
apiGetWindow(apiGetDesktopWindow(), GW_CHILD)<BR> Do Until hWndApp =
0<BR> If hWndApp <> Application.hWndAccessApp
Then<BR> hWndDb =
winGetHWndDB(hWndApp)<BR> If hWndDb <> 0
Then<BR> If sMyCaption =
winGetTitle(hWndDb) Then Exit Do<BR> End
If<BR> End If<BR> hWndApp =
apiGetWindow(hWndApp, GW_HWNDNEXT)<BR> Loop<BR> If hWndApp = 0
Then Exit Function<BR> If fConfirm Then<BR> If
MsgBox(sMyCaption & " is already open@"
_<BR> & "Do you want to open a second
instance of this database?@", _<BR> vbYesNo Or
vbQuestion Or vbDefaultButton2) = vbYes Then Exit Function<BR> End
If<BR> apiSetActiveWindow hWndApp<BR> If apiIsIconic(hWndApp)
Then<BR> apiShowWindowAsync hWndApp, SW_RESTORE<BR>
Else<BR> apiShowWindowAsync hWndApp, SW_SHOW<BR> End
If<BR> Application.Quit<BR>ProcEnd:<BR> Exit
Function<BR>ProcErr:<BR> MsgBox err.Description<BR> Resume
ProcEnd<BR>End Function<BR></FONT></DIV>
<DIV><FONT face=Arial size=2>...then put this as a RunCode in your AutoExec
macro</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>winCheckMultipleInstances (True) </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>...works like a charm in all versions ...HTH
:))))</DIV></FONT>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV>William Hindman<BR>So, then, to every man his chance -- to every man,
regardless of his birth, his shining golden opportunity -- to every man his
right to live, to work, to be himself, to become whatever his manhood and his
vision can combine to make him -- this, seeker, is the promise of America.
<BR>-- Thomas Wolfe </DIV>
<DIV> </DIV>
<DIV><BR> </DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=backroad@idir.net href="mailto:backroad@idir.net">Backroads
Data</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A
title=accessd@databaseadvisors.com
href="mailto:accessd@databaseadvisors.com">AccessD</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Tuesday, September 09, 2003 11:59
AM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> [AccessD] Automation between 2
applications</DIV>
<DIV><BR></DIV>
<DIV>Hello Group,</DIV>
<DIV> </DIV>
<DIV>I have 2 (related) questions on this subject...</DIV>
<DIV> </DIV>
<DIV>Question 1: If another application (it's not Access, I believe it's
C++) uses the Shell command to launch my Access application, and the Access
app is already open, will this simply make the Access app "active", or will
it launch a 2nd instance of it? (I'm wanting it to make my app active,
not open another copy.)</DIV>
<DIV> </DIV>
<DIV>Question 2: Is there any kind of "Application.Activation" event I can
hook into? If the above issue can be resolved to activate the Access
app, I need Access to go to a specific form and process a small amount of
data from the launching application. (I can do this if the other app
actually opens the Access app, but am not sure if I can call this processing
routine when the already-open app is activated.)</DIV>
<DIV> </DIV>
<DIV>Thanks in advance for any direction you can provide.</DIV>
<DIV> </DIV>
<DIV>Best Regards,</DIV>
<DIV> </DIV>
<DIV>Julie Schwalm<BR>Backroads Data<BR><A
href="http://www.backroadsdata.com">www.backroadsdata.com</A><BR>785-594-6807</DIV>
<P>
<HR>
<P></P>_______________________________________________<BR>AccessD mailing
list<BR>AccessD@databaseadvisors.com<BR>http://databaseadvisors.com/mailman/listinfo/accessd<BR>Website:
http://www.databaseadvisors.com<BR></BLOCKQUOTE>
<P>
<HR>
<P></P>_______________________________________________<BR>AccessD mailing
list<BR>AccessD@databaseadvisors.com<BR>http://databaseadvisors.com/mailman/listinfo/accessd<BR>Website:
http://www.databaseadvisors.com<BR></BLOCKQUOTE></BODY></HTML>