title: Variable not defined in VBA script
body: <p>I'm getting into the good habit of using <code>Option Explicit</code> at the top of all my MS Access VBA scripts. However, for this function it's giving me a <code>Variable not defined</code> error highlighting the line that begins with <code>Set objSysInfo =</code></p>
  
  <pre><code>Public Function GetUser(Optional whatpart = "username")
  
      Dim returnthis As String
      If whatpart = "username" Then GetUser = Environ("USERNAME"): Exit Function
      Set objSysInfo = CreateObject("ADSystemInfo")
      Set objUser = GetObject("LDAP://" &amp; objSysInfo.UserName)
      Select Case whatpart
          Case "fullname": returnthis = objUser.FullName
          Case "firstname", "givenname": returnthis = objUser.givenName
          Case "lastname": returnthis = objUser.LastName
          Case Else: returnthis = Environ("USERNAME")
      End Select
      GetUser = returnthis
  
  End Function
  </code></pre>
  
  <p>Might I be missing a specific reference?</p>