Greetings all,
I was asked via private message for the code I use to record who enters / edits the records in my application so I thought I would just post it here as well in case it could help someone else.
Background:
All tables have 4 fields that track who enters / edits records - the fields are:
Addedbyf, C, 10
AddDatef, Time, 17
Editedbyf, C, 10
Editdatef, Time, 17
When the application loads the user is presented with a dialog box that asks the user for their username and passwork. This username is verified against a table (along with the password). If everything is cool then the dialog sets a global variable (called gvuser)equal to the user's logon name and proceeds to load the app.
I then use the following code on each save button on each form. I should mention all my forms are modal as I want prevent any unintended changes to the data.
Code on Save Button
The whodidit function
I realize this is not complex stuff but it works pretty cool and it one of the things that could be included in a framework / best practices web page or online book as G. Gabriel has recently proposed (and I had proposed a few months back in another thread).
Regards,
Jeff
I was asked via private message for the code I use to record who enters / edits the records in my application so I thought I would just post it here as well in case it could help someone else.
Background:
All tables have 4 fields that track who enters / edits records - the fields are:
Addedbyf, C, 10
AddDatef, Time, 17
Editedbyf, C, 10
Editdatef, Time, 17
When the application loads the user is presented with a dialog box that asks the user for their username and passwork. This username is verified against a table (along with the password). If everything is cool then the dialog sets a global variable (called gvuser)equal to the user's logon name and proceeds to load the app.
I then use the following code on each save button on each form. I should mention all my forms are modal as I want prevent any unintended changes to the data.
Code on Save Button
Code:
'Call whodidit function to record who either added or edited the record 'I show the 4 fields from above on all forms but their tab stop property is disabled whodidit() 'Now save the record. topparent.commit()
The whodidit function
Code:
'Date Created: 22-Sep-2007 12:15:50 PM 'Last Updated: 22-Sep-2007 12:15:50 PM 'Created By : Jeff 'Updated By : Jeff FUNCTION whodidit AS C ( ) IF parentform.Mode_Get()="Enter" addedbyf.value=gvuser adddatef.value=now() end if IF parentform.Mode_Get()="Change" editedbyf.value=gvuser editdatef.value=now() end if END FUNCTION
Regards,
Jeff
Comment