Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

User Name and Date changed

Status
Not open for further replies.

dtutton

Technical User
Mar 28, 2001
58
0
0
DE
When I add a record in an access form, how can I update a user name field and date changed field.

Thanks
 
VBA - Form BeforeUpdate event assign the field values.

-Pete
 
Thanks Pete, What code do I use to get the system user id name

Thanks
 
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Public Function GetUser() As String
Dim UserName As String
UserName = String(100, "0")
GetUserName UserName, 100
GetUser = VBA.Left$(UserName, InStr(UserName, Chr$(0)) - 1)
End Function

taken from
-Pete
 
Thanks Pete,

Im showing my ignorance in Access - I think VBA is easier in Excel. How to I update the field with GetUser and Now. I tried:

Me![AddedBy].DefaultValue = GetUser
Me![AddedDate].DefaultValue = Now

in the BeforeUpdateEvent in a field in the sub-form but get an error(s). In the sub-form, I do not have a reference to the field in the data table.

David
 
i believe the easiest way would be to create a reference to the fields, and just make the objects not visible. then just assign the values to the objects.

-Pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top