This topic is locked

capturing date and time of database record changes

1/30/2007 2:30:07 PM
ASPRunnerPro General questions
G
Greg Cantwell author

I am using MS Access 2003 and aspRunner 4.12

I want to be able to capture the date and time of every "record update"

I have a "DateTime_Updated Field in my DB
Thanks in advance

C
clig 1/30/2007

Function BeforeEdit(dict, where)
' Parameters:

' dict - Scripting.Dictionary object.

' Each field on the Edit form represented as 'Field name'-'Field value' pair

' where - string with WHERE clause pointing to record to be edited
'** Custom code ****

' put your custom code here

dict("datetimeField") = Now()
BeforeEdit = True
' set BeforeEdit to True if you like to proceed with editing this record

' set it to False in other case
End Function

G
Greg Cantwell author 1/30/2007

I appreciate the quick response

We should discuss my skill sets 1st.

I'm going to need assistance on the coding itself.

It looks like I can write to my DateTime field from the view page: OnLoad in "Events"

Insert a record into another table?

I need th correct code to load the exact time and date into my DB...in the correct field
Once again, thanks for your patience and thanks in advance

Function BeforeEdit(dict, where)

' Parameters:

' dict - Scripting.Dictionary object.

' Each field on the Edit form represented as 'Field name'-'Field value' pair

' where - string with WHERE clause pointing to record to be edited
'** Custom code ****

' put your custom code here

dict("datetimeField") = Now()
BeforeEdit = True
' set BeforeEdit to True if you like to proceed with editing this record

' set it to False in other case
End Function

Sergey Kornilov admin 1/30/2007

Greg,
you are not making things clear enough.
When do you need to write a timestamp into datetime field?
Suggested code snippet allows you to do this when record is updated.

Is that what you looking for?

G
Greg Cantwell author 1/30/2007

Sergey,
Yes Sir...

When the "save" button used on the "edit" page

I would like to have the time & date of the update posted onto a db field that is in my master table.

Greg,

you are not making things clear enough.
When do you need to write a timestamp into datetime field?
Suggested code snippet allows you to do this when record is updated.

Is that what you looking for?

Sergey Kornilov admin 1/30/2007

Greg,
you like to update data in master table you need to build a SQL query and execute it.

Dim sSQL

sSQL = "update MasterTableName set DateTimeField where MasterTableID = " & SESSION(strTableName & "_masterkey1")

dbConnection.Execute sSQL


replace names in bold with actual field and table names.