how to get windows network users names into table

meprad

Registered User.
Local time
Today, 16:50
Joined
Sep 12, 2012
Messages
14
Dear friends,
I have created access database in 2010 (windows 7) that runs in network (multiuser platform) backend in shared drive and front end in each desktops. Now i want to record user information with date who have last changed the records. I have created a field in table as "user". I have also created a text box in a dataentry form; How can i get users' info. I am poor in VBA. Please help.

sorry i didn't made it clear. I would like to fetch user's name and date from the system after table update in multi-user environment. If other user updates the table then it has to be replaced from existing username. Please guide me how do i execute this.
Many thanks!
 
Last edited:
the simplest way is environ("username")

there are lots of other useful arguments for environ also


for x=1 to 30
msgbox(x & " " & environ(x))
next
 
Do you have access to a share point server? If so, i'd recommend that- as it has these features built in. if not, databasedev.co[dot]uk/get_username_or_computername.html

replace the [dot] with . sorry, i don't have 10 posts yet
 
HI there... Another fresh learner :)
I have been doing the same sort of thing reporting actions in a database such as form opened , closed . Onclick etc and recording the events to a security table for tracking

I have been using this

Code:
 DoCmd.SetWarnings False
  
  DoCmd.RunSQL "INSERT INTO TABLE_SECURITY_TRACKING ([UserName],[PCUsed],[Function])" & _
    "VALUES ('" & Environ("USERNAME") & "','" & Environ("COMPUTERNAME") & "', 'MASTERQC  Report Menu Form Exited')"
 
 DoCmd.SetWarnings True

This puts the USERNAME, Computer Name and the String of what's being done into the security table

May be of use to you :)
 
Thank you Dave, but don't know how and where i should write this code..
How can i get username from system after table update (using dataentry form) replacing the existing last user by the recent user.
many thanks!


the simplest way is environ("username")

there are lots of other useful arguments for environ also


for x=1 to 30
msgbox(x & " " & environ(x))
next
 
meprad, in your Form's Before Update event, just use..
Code:
Private Sub Form_Before_Update(Cancel As Integer)
    Me.[COLOR=Blue]lastUpdatedBy[/COLOR] = Environ$("username")
End Sub
where lastUpdatedBy would be the name of the control that is bound to the Field in the table.. The code Dave gave you is for to list all Environ variables.. that can go in a common module..
 
Thanks a lot Paul, it worked. but it returns the 'username' when I scroll the records without updating any fields in the form. How it is possible to record username only after any change made in the attribute of a form.
 
Then try the Form On Dirty event, rather than Before Update..

However BeforeUpdate will only be triggered if the Form has been dirtied.. So does your Form have any code somewhere that modifies entries? For Load, Current, Open any associated events.. do they have any code where they change or add values? If so, that is why it is updating the field even though there is no manual intervention..
 
Dear Paul - phewww !! that rocked when code executed from "on dirty" event. does it make any difference in any way??
you are a super access hero. Millions of thanks Paul your help is really appreciated. I got exactly what i wanted.

to your question if I have used code in the form; yes i used two statements
Private Sub Form_Current()
RecordSource: Me!ID = Me.ID
RunCommand acCmdSaveRecord
End Sub
for immediately saving the record (without record locking)

Mousewheel statement (hope you got it)

thank you Paul for all your help. I will post some other issues on the days to come.
 
Dear Paul - phewww !! .....
you are a super access hero.
I am flattered, but TBH I am still a learner.. I learn new stuff everyday.. Over here and on my work.. I am just sharing what I have learned.. And am glad to have helped.. :)
does it make any difference in any way??
Well BeforeUpdate is called when an Explicit Save is performed or when you move to a different record.. On Dirty is called when any change in the Form has been made.. So which is what you wanted.. In this case On Dirty would be the best method to use..
 
Dear friends,
I have two combo boxes in Access form. what i want is lets say combo1 = "A" then combo2="x". Note that combo1 has list A,B,C and combo2 has list X,Y,Z. Your help is well appreciated.

Prad
 
Prad, Try the AfterUpdate event of the ComboBox.. Then use a IfElse or Select to assign the appropriate value on the second combo..Something along the lines of..
Code:
Private Sub comboBoxName1_AfterUpdate()
    If Me.comboBoxName1 = "A" Then
        Me.comboBoxName2 = "X"
    ElseIf Me.comboBoxName1 = "B" Then
        Me.comboBoxName2 = "Y"
    Else
        Me.comboBoxName2 = "Z"
    End If
End Sub
 
how to get combo2 value after updating combo1 of access form

Thank you Paul, but it doesn't seem to be working, sorry for not being that clear. what i want is if i select "A" from combo1, I want to have one value could it be "x" or "y" or "z" but of my choice.. there is no link between these two combos. After combo1 is selected "A", I want automatically pop, lets say, "y" or any value i want may be "z" at combo2 of the form. :-)
Please note that both combos are fetched from tables that contains two columns (ID, name) and combos are fetched by binding first column and assigned column count 2; so that it shows the values rather than numbers. Moreover, the combos are allowed to store multiple values (defined in master table)

Many thanks
Prad
 
Last edited:

Users who are viewing this thread

Back
Top Bottom