Geordie2008
Registered User.
- Local time
- Today, 23:18
- Joined
- Mar 25, 2008
- Messages
- 177
Hi all,
I have a form which populates a table. When the form is used I would like to populate the table with the "username" of the person who po[pulated it.
Previously I used to use:
=Environ("UserName") in the default value of the table.
However, now that Im on XP from reading this forum I understand I need to use the following code:
'This function is used to allow the use of the Environ function in Access 2003
Public Function fGetUserName()
On Error GoTo Err_fGetUserName
fGetUserName = VBA.Environ("UserName")
Exit_fGetUserName:
Exit Function
Err_fGetUserName:
MsgBox Err.Number & " - " & Err.Description
Resume Exit_fGetUserName
End Function
So far I have put this in the "Properties" ----> "Event" -----> "Before Update" and "After Update" as an "event procedure"
This returns the value "#Name?"
Im sure the code is fine and that I am just putting it in the wrong place...
Could someone please advise?
I would like the form to display the username and also populate it in a field in the database (called "RecordUser") when any changes are made to the values within the form.
Regards
Mandy
I have a form which populates a table. When the form is used I would like to populate the table with the "username" of the person who po[pulated it.
Previously I used to use:
=Environ("UserName") in the default value of the table.
However, now that Im on XP from reading this forum I understand I need to use the following code:
'This function is used to allow the use of the Environ function in Access 2003
Public Function fGetUserName()
On Error GoTo Err_fGetUserName
fGetUserName = VBA.Environ("UserName")
Exit_fGetUserName:
Exit Function
Err_fGetUserName:
MsgBox Err.Number & " - " & Err.Description
Resume Exit_fGetUserName
End Function
So far I have put this in the "Properties" ----> "Event" -----> "Before Update" and "After Update" as an "event procedure"
This returns the value "#Name?"
Im sure the code is fine and that I am just putting it in the wrong place...
Could someone please advise?
I would like the form to display the username and also populate it in a field in the database (called "RecordUser") when any changes are made to the values within the form.
Regards
Mandy