Solved

winCheckMultipleInstances

Posted on 2013-12-01
14
219 Views
Last Modified: 2013-12-29
i am trying to prevent users fro opening a second instance of the database using winCheckMultipleInstances.The problem is that it isn't working in windows 7 64bit and ms access 2010 32 bit.i have tried using a short cut and opening the database directly.Is there an working alternative.Thanks
0
Comment
Question by:Svgmassive
  • 6
  • 6
  • 2
14 Comments
 
LVL 75

Expert Comment

by:DatabaseMX (Joe Anderson - Access MVP)
Comment Utility
What/where is 'winCheckMultipleInstances' ??
Are you talking about a 2nd instance on the same system, or just a 2nd instance anywhere ?

mx
0
 

Author Comment

by:Svgmassive
Comment Utility
Second instance on same system
0
 

Author Comment

by:Svgmassive
Comment Utility
I am running it from an autoexec function
0
 
LVL 75

Expert Comment

by:DatabaseMX (Joe Anderson - Access MVP)
Comment Utility
Well, I know the author of that code and I'm sure it works.  But I suppose there could be an issue with Win7x64, although I'm not sure why there would be.
Has the code ever worked for you ?

Also just curious, how would a 2nd instance of your db get opened on the *same* system anyway ?

mx
0
 

Author Comment

by:Svgmassive
Comment Utility
yep
0
 

Author Comment

by:Svgmassive
Comment Utility
i think the problem is with the   sMyCaption = winGetTitle(winGetHWndDB()) it's returning a "" not sure if this is correct,an alternative is to check the task manager.i don't know if the will work.
0
 
LVL 75

Expert Comment

by:DatabaseMX (Joe Anderson - Access MVP)
Comment Utility
just curious, how would a 2nd instance of your db get opened on the *same* system anyway ?
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 75

Expert Comment

by:DatabaseMX (Joe Anderson - Access MVP)
Comment Utility
Also what  version of Access / Windows did you have this working in ?
0
 
LVL 75

Expert Comment

by:DatabaseMX (Joe Anderson - Access MVP)
Comment Utility
I  have pinged the author of that code. He is in NZ ... time zone difference.  Let's see what he comes up with ...

mx
0
 
LVL 20

Accepted Solution

by:
GrahamMandeno earned 500 total points
Comment Utility
Hi Svgmassive

I confess to being the author of that code :-)

It was written almost 20 years ago for Access 2.0, and worked beautifully until Access 2007.  

The problem is that it works by checking the title bar text of the Database window, which used to be guaranteed to show the filename of the database, even if the user had changed the application window title.  With Access 2007, the Database window disappeared and was replaced with the Nav Pane, which has no title text.

A reasonable workaround is to use a shortcut with the /excl command line switch to open the database exclusively.  You must include the full path to msaccess.exe in the command line - like this:

"C:\Program Files (x86)\Microsoft Office\Office14\msaccess.exe" "C:\Your Path\Your database.accdb" /excl

Note that in a multi-user environment you should always give each user a separate copy of the front-end on the local hard drive, so there will never be any problem of locking other users out by using the /excl switch.

Best wishes,
Graham Mandeno [Access MVP since 1996]
0
 

Author Comment

by:Svgmassive
Comment Utility
Thanks graham for taking the time..never had a problem before with it...will try the work around later.can the task manger be used as an alternative
0
 

Author Comment

by:Svgmassive
Comment Utility
Databasmx thanks. Any suggestions
0
 
LVL 20

Expert Comment

by:GrahamMandeno
Comment Utility
I can't see how the task manager could be used for this.

You could conceivably check the title text of the main application window, but this is fraught with difficulty - for example:
- the user can change the text, or it can be changed by code
- the title changes with DoCmd.Maximize and DoCmd.Restore
- the format changes with different Access versions

The only really fool-proof method I can think of is to use API calls to inspect the file handles for all the other Access processes, and see if any of them have the current DB open, but this is getting into some pretty heavy-duty I/O subsystem coding.

I recommend the /excl switch - it works well for me :-)

Note that you can also set the "Default open database mode" to "Exclusive" in the Access options.  This is a per-user setting, so will need to be set for each user's profile.

-- Graham
0
 
LVL 75

Expert Comment

by:DatabaseMX (Joe Anderson - Access MVP)
Comment Utility
"Databasmx thanks. Any suggestions"
Well since Graham is here ... :-)
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This very simple solution applies to a narrow cross-section of the "needs to close" variety. In this case, the full message in Event Viewer was in applog, Event ID 1000: Faulting application iexplore.exe, version 8.0.6001.18702, faulting module …
As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now