Hello,
I have the following code that checks to make sure associates, other than myself, are not accessing my Access database from the main share-drive location and that the associates are using a local copy on their desktop. The code was originally writtien so that I - the main developer - could enter the database from the main location. However, I need to add one other associate to have access to open the database from the main location. I cannot get the "OR" statement to work to save my life. Each iteration ends up throwing the message box that is written in the code. I have tried multiple variations with parenthesis, also.
Does this make sense? Thank you in advance for your help.
I have the following code that checks to make sure associates, other than myself, are not accessing my Access database from the main share-drive location and that the associates are using a local copy on their desktop. The code was originally writtien so that I - the main developer - could enter the database from the main location. However, I need to add one other associate to have access to open the database from the main location. I cannot get the "OR" statement to work to save my life. Each iteration ends up throwing the message box that is written in the code. I have tried multiple variations with parenthesis, also.
Does this make sense? Thank you in advance for your help.
PHP:
Dim strPath As String
strPath = CurrentProject.Path
If ((Environ("Username") <> "user1" And InStr(strPath, "z:\") > 0) Or (Environ("Username") <> "user2" And InStr(strPath, "z:\") > 0)) Then
MsgBox "You are attempting to use the main copy of this database. You need to COPY and PASTE this database to your desktop to create a local reference. The database will now close.", vbExclamation
DoCmd.Quit
End If
PHP:
Dim strPath As String
strPath = CurrentProject.Path
If ((Environ("Username") <> "user1" or Environ("Username") <> "user1") And InStr(strPath, "z:\") > 0) Then
MsgBox "You are attempting to use the main copy of this database. You need to COPY and PASTE this database to your desktop to create a local reference. The database will now close.", vbExclamation
DoCmd.Quit
End If