Adding a user id in a table for newbs

Braindead90

New member
Local time
Today, 12:31
Joined
Oct 10, 2013
Messages
7
Hello, I am trying to add a user stamp in a table. I have seen online that perople put a macro (Before Change) in microsoft access 2010 but I dont understand how to use that.

I have seen you are suppose to do something with = Environ("username")
 
Use VBA Code. http://www.baldyweb.com/FirstVBA.htm
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
    Me.[COLOR=Blue]yourControlToField [/COLOR]= Environ("username")
End Sub
Where yourControlToField is the name of the control which is bound to the field in the table you wish to update.
 
Paul,

Sorry to hijack this thread...

I have been using an api (fOSUsername by Dev Ashish http://www.databasedev.co.uk/get_username_or_computername.html ) to do this but the Environ solution is much easier.

Do you know if there any upsides to using the api instead or anything I risk but converting over to to the environ method?

Thanks!
 
Do you know if there any upsides to using the api instead or anything I risk but converting over to to the environ method?
Environmental variables are prone to manipulation. Anyone with a little bit of experience and who know what they are doing can edit the values held within the Environmental variables. However the API that you are using, is stable. If given an option between usage of Environ and API, I would go with API all the way ! ;)
 
Especially since you've already gone to the effort of setting up the API call.
 
Question: Mine only shows before change and before delete, where do I find before update?
 
Also I tried using before change, but I am alerted that "the function environ is not a valid expression used in data macros"
 
You are supposed to be using this in VBA not in a macro

If you click on the control, you should see a before update under events. Select Event procedure and enter the code.
 
I just realized that your post is in the tables section and you want to do this in a table. You need to do this on a FORM. You can put the field into your table but the data will be updated in the form.

You could try entering it into to the before update of the whole form and see if that works. If not, you may need to do it in the before update on specific fields.
 

Users who are viewing this thread

Back
Top Bottom