add last_updated_by and last_updated_date in form (1 Viewer)

akika

Registered User.
Local time
Yesterday, 19:18
Joined
Aug 7, 2018
Messages
102
hi
in access2016 form, i have 5fields (name, address, phone, email and comments) that read from table tbl_customer
how can i add the
last_updated_by (user that has login) and last_updated_date (date/time)fields.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 19:18
Joined
Oct 29, 2018
Messages
21,453
Are those two fields available from the same table where your other fields on the form are coming from? If so, you can go to the form's design view, click on Field List button on the Ribbon and then should be able to drag the fields you want to add from the list on to the form.
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 22:18
Joined
Feb 19, 2002
Messages
43,223
The two fields must be added to the table and also to the query used as the RecordSource for the form. The fields do not have to be bound to controls unless you want the values to be visible to the user. If you bind these fields to controls, you MUST lock the controls so the user cannot update the values.

Then, in the Form's BeforeUpdate event:

Me.last_updated_by = Forms!frmLogin!txtUserID (or some other method if you don't use a login form)
Me.last_updated_date = Now()
 

akika

Registered User.
Local time
Yesterday, 19:18
Joined
Aug 7, 2018
Messages
102
Thanks the last modified user & date is working. :)
along with the last modified, how can i add another field "No_Of form data changed"
that get incremented each time that a change is done to that form?
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 19:18
Joined
Oct 29, 2018
Messages
21,453
Thanks the last modified user & date is working. :)
along with the last modified, how can i add another field "No_Of form data changed"
that get incremented each time that a change is done to that form?
That request might require a little bit more clarification. What's considered as a change to count as 1? Otherwise, if you're simply trying to increment a counter each time both the modified by and modified date are updated, then simply add a 1 to the existing value in the field. For example:
Code:
Me.CounterFieldName = Me.ConterFieldName + 1
Hope it helps...
 

Users who are viewing this thread

Top Bottom