[AccessD] Same FE open twice (or more)

jwcolby jwcolby at colbyconsulting.com
Thu Jan 31 13:31:14 CST 2008


Thanks, I'll give it a try. 


John W. Colby
Colby Consulting
www.ColbyConsulting.com 
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Mark A Matte
Sent: Thursday, January 31, 2008 2:02 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Same FE open twice (or more)



John,

Several years ago I needed to limit how many times a user could open the
front end at the same time.  I used a call to count the windows open
everytime the app was launched.  I believe you could do the same...but
instead of not allowing...just logging it.  Below is copied from A97.
fyi...in the example below the app name started with 'MANCR'(need to know
what you're counting and why I used "StrAppCaption = left(StrAppCaption, 5)"
to limit to 5 char...)

Let me know,

Thanks,

Mark A. Matte

 ********************START*************
Private Sub Form_Open(Cancel As Integer)
     If GetCountOfWindows(hWndAccessApp, "MANCR")> 1 Then
         Cancel = True
         msgbox "Please use the instance of MANCR that is " _
                & "already open."
         DoCmd.Quit acQuitSaveNone
      End If
End Sub

      ' This function counts all instances of an application that are open,
      ' including any windows that are not visible.
      ' Arguments: LngHwnd        = Any valid window handle.
      '            StrAppCaption  = The window caption to search for.
      ' Example:   GetCountOfWindows(hWndAccessApp,"Microsoft Access")
      Function GetCountOfWindows(Lnghwnd, StrAppCaption)
         Dim LngResult As Long
         Dim LngICount As Long
         Dim StrAppName As String

         LngResult = GetWindow(Lnghwnd, GW_HWNDFIRST)
         Do Until LngResult = 0
            If IsWindowVisible(LngResult) Then
               StrAppName = GetAppName(LngResult)
               StrAppCaption = left(StrAppCaption, 5)
               If InStr(1, StrAppName, StrAppCaption) Then
                  LngICount = LngICount + 1
               End If
            End If
            LngResult = GetWindow(LngResult, GW_HWNDNEXT)
         Loop
         GetCountOfWindows = LngICount
         End Function

********************END*************

> From: jwcolby at colbyconsulting.com
> To: accessd at databaseadvisors.com
> Date: Thu, 31 Jan 2008 12:19:55 -0500
> Subject: Re: [AccessD] Same FE open twice (or more)
>
> In fact I do not want to prevent the user from opening it twice, 
> unless it is causing a problem which I haven't determined yet. I just 
> want to see the count of a user in a database or something like that.
>
>
> John W. Colby
> Colby Consulting
> www.ColbyConsulting.com
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Gustav 
> Brock
> Sent: Thursday, January 31, 2008 12:07 PM
> To: accessd at databaseadvisors.com
> Subject: Re: [AccessD] Same FE open twice (or more)
>
> Hi John
>
> That is quite easy if you can persuade the users to launch your app 
> via a shortcut (and if you read the command line when launching the 
> app, you can quit if no params exists - see recent thread on this) 
> which forces the frontend to be opened exclusively. If opened already, 
> catch that error and display a message.
>
> /gustav
>
>>>> jwcolby at colbyconsulting.com 31-01-2008 17:48>>>
> Is there any way to discover that a user has opened the database more 
> than one time? I have users who do this, and while I don't care, I 
> think that it might be causing issues. I have built a rather elaborate 
> error logging system to log error number, error message, code module, 
> function, line number, workstation, user, time and date. I have the 
> majority of errors coming from specific users and am trying to 
> discover why. Some of them have mentioned that they do use the FE 
> opened more than once at a time so I want to check if these specific 
> users are doing that at the instance that the error occurs.
>
> John W. Colby
> Colby Consulting
> www.ColbyConsulting.com
>
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com

_________________________________________________________________
Connect and share in new ways with Windows Live.
http://www.windowslive.com/share.html?ocid=TXT_TAGHM_Wave2_sharelife_012008
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list