Date Modified/Time Stamp

  • Thread starter Thread starter Elvis72
  • Start date Start date
E

Elvis72

I have a Main Form that has many subforms on it.

I need to see the last time the record was modified somewhere on the main
form.

I have seen how to make it where it is just a form, but if they go in and
modify a related subform then I need that to show up too.

Any questions or information needed please let me know!~
 
hi,
I have seen how to make it where it is just a form, but if they go in and
modify a related subform then I need that to show up too.
Add the timestamp field to each table. Use the Before Update event in
your subforms to set the timestamp.

Use a union query to get the history:

SELECT TableName, ID, Timestamp FROM
(
SELECT 'table1' AS TableName, ID, Timestamp FROM table1
UNION ALL
....
UNION ALL
SELECT 'tableN', ID, Timestamp FROM tableN
) Q
ORDER BY Timestamp

This might be overkill. In the case you don't need that much
information, just store the timestamp in your main table. Use the Before
Update event in your subforms to set the value in your main table, e.g.

SQL = "UPDATE mainTable SET timestamp = Now() WHERE Id = " & _
Me.Parent.Form![ID]
CurrentDb.Execute SQL, dbFailOnError


mfG
--> stefan <--
 
In the Form After Update event of each of your subforms:

Me.Parent.txtTimeStamp = Now

txtTimeStamp should be a control on the main form bound to the field in the
main form's recordset where you want to store the last updated value.
 
Klatuu -

I implemented your After Update and I am getting this message:

Microsoft Office Access Can't find the macro 'Me'

Which I'm not sure what it is looking for?

Here is what I have for the After Update:

Me.FrmConstructionServices - All Records.txtTimeStamp = Now
 
You are mixing syntax
Me.FrmConstructionServices - All Records.txtTimeStamp = Now

Me is a name that refers to the current form. It appears your form name is
FrmConstructionServices - All Records. If that is so, then to use a form
name with spaces in it, it has to be enclosed in brackets:
[FrmConstructionServices - All Records]

But, all you need is:
Me.txtTimeStamp = Now

That assumes FrmConstructionServices - All Records is the main form and the
code is in the main form module.

Now, to do your subforms, the correct syntax is
Me.Parent.txtTimeStamp = Now
 
Klatuu -

I have tried the below in both the before and after update events, and I'm
getting the error can't find the '.' macro.

AND now I'm getting

Run-time error '-2147352567 (80020009

You can't assign a value to this object.

When editing a field.

Klatuu said:
You are mixing syntax
Me.FrmConstructionServices - All Records.txtTimeStamp = Now

Me is a name that refers to the current form. It appears your form name is
FrmConstructionServices - All Records. If that is so, then to use a form
name with spaces in it, it has to be enclosed in brackets:
[FrmConstructionServices - All Records]

But, all you need is:
Me.txtTimeStamp = Now

That assumes FrmConstructionServices - All Records is the main form and the
code is in the main form module.

Now, to do your subforms, the correct syntax is
Me.Parent.txtTimeStamp = Now
--
Dave Hargis, Microsoft Access MVP


Elvis72 said:
Klatuu -

I implemented your After Update and I am getting this message:

Microsoft Office Access Can't find the macro 'Me'

Which I'm not sure what it is looking for?

Here is what I have for the After Update:

Me.FrmConstructionServices - All Records.txtTimeStamp = Now
 
hi,

I have tried the below in both the before and after update events, and I'm
getting the error can't find the '.' macro.
Yup, Klatuu answers is VBA code not a macro. So you need an event
procedure. If it still doesn't work, post your entire event procedure code.


mfG
--> stefan <--
 
Back
Top