Opening the Wrong Database

Learn2010

Registered User.
Local time
Today, 13:46
Joined
Sep 15, 2010
Messages
415
I was moved from a project for a while and then brought back to it. I had two programs that were being used in this project. I had a process set up that used something similar to the following line of code:

Shell "WScript " & """C:\MyFolder\MyFile.vbs"""

This would run a script that would close the first Access program and open another Access program. The other program used something similar, only it was in another folder. The idea is to open and close these two programs programmatically versus closing and opening them manually.

What I found upon my return was that instead of leaving the file in the folder it was designed to be in, it was copied to the desktop, instead of using the shortcut on the desktop. Once the script was run, it would open the file in the folder, not the one on the desktop.

This has created problems. I have to make changes on the fly and update the databases. If I update the one in the folder, and they use the one on the desktop, there is sometimes a problem.

Without saying too much more, my question is this. Can I get the program to recognize that it is not in the correct location when it is opened? If they copy it to the desktop and open it there, can I get it to shut down or give a warning message, or? I am open to suggestions?

Thank you.
 
CurrentProject.Path will tell you where it is located. If you can parse that for the folder you're looking for, it should tell you if it's been moved. What you do after that is up to you... go yell at the user manually, move it back with a script, who knows? :D
 
I am not sure how to use that. Can you elaborate a little?

Thank you.
 
I use it in the Load event of my Switchboards, to make sure they're not loading the FE version on the server (by looking for a substring). If it is the server copy, it warns them to use their desktop version and closes the DB.

In your VBA immediate window, try
Code:
? CurrentProject.Path
and see what you get.
 

Users who are viewing this thread

Back
Top Bottom