Need help with code to prevent mde from running twice

threeo2

Registered User.
Local time
Today, 20:33
Joined
Feb 11, 2003
Messages
31
I have a split db using access 2002. The FE's are mde running ny various machines on my network. My BE is MDB. On each machine the user starts an .exe file that i wrote in vb6 that checks the Server version # of the mde FE and then copies it to the local machine if it needs to be updated. This all works fine and dandy and is fairly simple.

If the mde is current it simpy opens my mde and closes my .exe updater.

The problem is that this will allow you to open more than one copy of the mde file. Most of my users use the quick launch in the windows taskbar so they are commonly double clicking which almost always will open two copies of my mde. I have tried to explain to my users that you only need to click the quick launch icons once till i'm blue in the face! (These are people who have been using computers every day for 2-3 years and still don't know when to click once or twice).

What i would like to do is detect if my mde file (or MSACCESS.EXE) is already running so i can keep it from being run again. I have found a few leads in the forum but nothing solid.
Any suggestions will be a great help! below is the code i am using ot start me mde file.


ShellExecute Me.hwnd, vbNullString, "c:\Green Enterprises\GreenDB.mde", vbNullString, "C:\", SW_SHOWNORMAL
 
Hi threeo2

Probably to help you i'll need that function in vb.
 
Searching the forum is a great way to discover and learn the answers to your Access
programming questions.

You need to use the AppActivate statement. This code will test if the calculator
is already open, if true it will set the focus to it, if false then it will open the
calc.exe program.
Code:
Public Function OpenCalculator_Click()
On Error GoTo Err_OpenCalculator_Click
    
    AppActivate "Calculator", False 'Programs Title Bar Name
    
Exit_OpenCalculator_Click:
    Exit Function
    
Err_OpenCalculator_Click:
    If Err.Number = 5 Then 'Invalid procedure call or argument
        Call Shell("C:\Windows\System32\calc.exe", vbNormalFocus)
    Else
        MsgBox Err.Number & " - " & Err.Description
        Resume Exit_OpenCalculator_Click
    End If
    
End Function
 

Users who are viewing this thread

Back
Top Bottom