Question : Unknown error on Environ("Username")

I have a database in Access 2002-2003 format.  One form has a field where the table-level default is the expression =Environ("Username").  This field relates to another table (lookup wizard, limited to the list values), where the username is the primary key for users' contact information.  Other than startup restrictions, the database has no other security (user-level, encryption, etc.).

When I test the database from my local hard drive and from a shared network drive, I have no problems.  However, from the shared network drive, when other users try to open that form (I've tested with two other users), they get the application message, "There was an error executing the command".  However, I still have no problems.

From another question on this site, I tried replacing =Environ("Username") with the function at http://www.mvps.org/access/api/api0008.htm.  However, those two other users still get the same message, but I still have no problem.  Thus, I don't think it's the function causing the error.  Also, I checked the spelling of the usernames in the related table, and they are correct.

I would say it's some kind of difference between me and the other two users, but we all work for the same company and run off identical systems (Windows XP and Office 2003) with all the same updates and patches.

What could be causing this?

Answer : Unknown error on Environ("Username")


you are not trying to call the api fuction from the table directly are you? That just does not work. I typically get the logged on users name when my apps start and then stuff that into a variable that I return from a function call and then whenever I need it, in your case it sounds like you want to record who is creating a records, I just call my function.

Private Sub Form_BeforeUpdate(Cancel As Integer)
    'after all of your other validation code ...
    Me.CreateUser.Value = getUserName
End Sub

Steve
Random Solutions  
 
programming4us programming4us