I'm afraid you haven't tested that very well. That logic is flawed in multiple ways. Not least because other users would not typically have access to the file if it's saved within your profile (as it seems to be).
The first thing you need to do is to move it somewhere generally accessible. If it's on a network then it's the network address you need to check, and maybe an extra check if your PC is sharing it as you would not then typically be using the network version of the address even if you were accessing the same database.
The following code can be considered as a template. It won't work as it stands as I have far too little information to work with :
- Private Const conMDBName As String = "DisablePath.mdb"
-
Private Const conLocal As String = "C:\LocalPath\" & conMDBName
-
Private Const conNetwork As String = "\\Server\Share\NetworkPath\" & conMDBName
-
-
Private Sub Form_Open(Cancel As Integer)
-
Dim DP As DAO.Database
-
-
Set DP = CurrentDb
-
If DP.Name = conLocal Or DP.Name = conNetwork Then Exit Sub
-
Call MsgBox("You are not in the original source. " & _
-
"Please ask your Database admin for help")
-
Call DoCmd.Quit
-
End Sub