title: Access 2010 - VBA Command to Close Database if Opened in a Specific Location
body: <p>I am trying to create an event procedure when the form loads that will close the database if the file is accessed from a specific location on a shared drive.</p>
  
  <p>My first attempt looked something like this:</p>
  
  <pre><code>On Error Resume Next
  Dim GetPath As String
  GetPath = CurrentProject.Path
  If GetPath = "C:\Folder1\Folder2" Then
      DoCmd.Quit
  End If
  </code></pre>
  
  <p>However, since this file is located on a shared drive, users may be accessing the file from different drives (but the same server/pathway). So, for example, in my code the C drive wouldn't work for everyone. Some users may be accessing the server from J drive or L drive on their computer.</p>
  
  <p>Is there a way I can get around this, or is there a better method?</p>
  
  <p>Note: One way I could get around this problem would be to, instead, say</p>
  
  <pre><code>If GetPath &lt;&gt; "desired pathway" Then 
  DoCmd.Quit
  </code></pre>
  
  <p>But I want to avoid this if possible.</p>