Help with CurrentProject.Path and CurrentProject.FullName

B

Bill Davis

I am trying to write a routine for the Onload Event of my splash screen
to verify that the copy of the database is located on specific server
and folder before it will run. This code If CurrentProject.FullName<>
E:\Files\Sales\SalesOrder.mdb then
Msgbox "Access Denied"
Docmd.Quit works if I use the drive E: but there are several user that
do not have there drive mapped to E:, so I have tried to use
\\OH38783\Files\Sales\SalesOrder.mdb but it does not work, do anyone
have any ideal of how to get this to work or something else that will
work with a network drive?
Thanks Bill
 
A

Allen Browne

The UNC path name should work.

Perhaps people are using different paths as well. Could you use the Connect
property of a TableDef (one of the attached tables) to get the path, e.g.:
If CurrentProject.FullName <> dbEngine(0)(0).TableDefs("Table1").Connect
Then

BTW, you're not putting everyone into the same copy of the mdb are you? You
really need to split that database if you have multiple users. If that's a
new concept, see:
http://allenbrowne.com/ser-01.html
 
B

Brendan Reynolds

I tried a few tests, and it appears that CurrentProject.FullName will return
either the UNC name or the mapped drive and path, depending on how the user
connected to the server, which is going to make things a bit tricky for you
if you have some users connecting to the server using UNC and some using
mapped drives.

There's some code at the following URL to get the UNC path of a mapped drive
....

http://www.mvps.org/access/api/api0003.htm

Perhaps you could do something like this (untested air-code) ...

strPath = CurrentProject.Path
If Mid$(strPath, 2, 1) = ":" Then
strUncPath = fGetUncPath(Left$(strPath, 2)
End If

The function 'fGetUncPath' is part of the code at the above URL.
 
Top