Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Unknown error on Environ("Username")

Posted on 2007-03-28
3
Medium Priority
?
631 Views
Last Modified: 2008-02-01
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?
0
Comment
Question by:matsumotod
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 39

Accepted Solution

by:
stevbe earned 1000 total points
ID: 18812397
<One form has a field where the table-level default >
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
0
 

Author Comment

by:matsumotod
ID: 18816144
Where in VB Editor would I put that code?  A new module?  If so, before or after the "Option Compare Database Option Explicit"?  (I'm an accountant, only knowing enough about programming to be dangerous.)

I don't know what an API function is, so a little more on my setup - there's a main "Courses" table, that has a few lookup fields related to three other tables' records via the primary keys.  The "Participant" lookup field is related to the "People" table, where the username is the primary key.  The default for "Participant" is the =Environ("Username").  I've created a query that is basically a duplicate of the "Courses" table.  However, the query criteria is set to be =Environ("Username") for "Participant".  This query feeds a form for data entry (both editing current records and adding new ones), where the "Participant" field is disabled - that is, the users can see that they're being identified as the participant, but they can't change it.
0
 

Author Comment

by:matsumotod
ID: 18816630
I think I figured it out - it was two-fold.  First, I did need to take the function out of the table default.  Second, I had to disable "sandbox mode" on that function - see http://www.access-programmers.co.uk/forums/showthread.php?t=76173.
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question