PaulClough
New member
- Local time
- Today, 13:48
- Joined
- Aug 6, 2012
- Messages
- 7
Many systems need to record who & when created a record and updated a record as an audit trail. But access seems to make this simple need hard to accomplish. I am using ACCESS 2007
I have researched this but seem to be missing something elemental.
I have found code for getting the user name from the system and can get it to run in a field on the form. But I can't get the data to save to the table.
This is actually a subform but I need to accomplish this also for the main form.
I can put =Now() in the Data control source of a text box and get the date & time, but how do also put in the Data control source the table.form.field.name,ie.[ctCurExpTranx].[ctWhenUpdated] or
[ctCurExpTranx].[ctWhoUpdated] so that the system knows to put the user name or date-time into these fields so they can get saved to the underlying table.
I also realize that somehow I need to do this update only if some field(s) on the form is actually changed and not just viewed.
I also have two similar fields for when the record is created and I would like to use the Default field to have this data automatically updated.
Since VBA for access seems rather complicated still, I am tring to use other methods than long VBA programs to accomplish such a simple task. For this simple application this simple function is fine because of low security and users barely know simple formulas. I just want to know who may need some help due to data entry problems & who has forgotten to make their updates.
Public Function GetUserName() As String
GetUserName = Environ("UserName")
End Function
I put this in a module and put =GetUserName() in the data control source, but again how does this data get to my table.
I look at event procedures & macro events but AGAIN, I must be missing something elemental. The user name and date-time are not in the table when I check it, even though they display on the form screen.
The solutions I have seen have all left out the elemental point I am missing. I can type data into a form field & it saves to the table fine, but If I use a function or something to get the data & don't know how to make the system think I typed it in so it will save the data to the field.
Your help is appreciated,
Paul
I have researched this but seem to be missing something elemental.
I have found code for getting the user name from the system and can get it to run in a field on the form. But I can't get the data to save to the table.
This is actually a subform but I need to accomplish this also for the main form.
I can put =Now() in the Data control source of a text box and get the date & time, but how do also put in the Data control source the table.form.field.name,ie.[ctCurExpTranx].[ctWhenUpdated] or
[ctCurExpTranx].[ctWhoUpdated] so that the system knows to put the user name or date-time into these fields so they can get saved to the underlying table.
I also realize that somehow I need to do this update only if some field(s) on the form is actually changed and not just viewed.
I also have two similar fields for when the record is created and I would like to use the Default field to have this data automatically updated.
Since VBA for access seems rather complicated still, I am tring to use other methods than long VBA programs to accomplish such a simple task. For this simple application this simple function is fine because of low security and users barely know simple formulas. I just want to know who may need some help due to data entry problems & who has forgotten to make their updates.
Public Function GetUserName() As String
GetUserName = Environ("UserName")
End Function
I put this in a module and put =GetUserName() in the data control source, but again how does this data get to my table.
I look at event procedures & macro events but AGAIN, I must be missing something elemental. The user name and date-time are not in the table when I check it, even though they display on the form screen.
The solutions I have seen have all left out the elemental point I am missing. I can type data into a form field & it saves to the table fine, but If I use a function or something to get the data & don't know how to make the system think I typed it in so it will save the data to the field.
Your help is appreciated,
Paul