'Date Modified' field

W

Wayne G. Dengel

To The Group:

I have a set of records, data entered some time ago. When I open AND modify
an old record, I would like to have a field that will display the current
date only when said record is modified. This will yield a 'Last Modified'
date. Each time the record is again updated/changed for any reason, I would
like the same field to reflect the new date.

Is this something that can be easily added? (I know how to add fields, etc,
just do not have a handle on how to automatically enter a date IF and only
if the record is modified.

Regards.
Wayne
 
R

Rick Brandt

Wayne G. Dengel said:
To The Group:

I have a set of records, data entered some time ago. When I open AND modify
an old record, I would like to have a field that will display the current
date only when said record is modified. This will yield a 'Last Modified'
date. Each time the record is again updated/changed for any reason, I would
like the same field to reflect the new date.

Is this something that can be easily added? (I know how to add fields, etc,
just do not have a handle on how to automatically enter a date IF and only
if the record is modified.

This is easily done when modifications to the data is made through a form. Just use
the Form's BeforeUpdate event.

Me![Last Modified] = Now() 'Date and time
or
Me![Last Modified] = Date() 'Date Only
 
W

Wayne G. Dengel

Rick: Pls pardon the ignorance (lack of experience), specifically, how do I
use/enter the procedure you refer to below?
Wayne




Rick Brandt said:
Wayne G. Dengel said:
To The Group:

I have a set of records, data entered some time ago. When I open AND modify
an old record, I would like to have a field that will display the current
date only when said record is modified. This will yield a 'Last Modified'
date. Each time the record is again updated/changed for any reason, I would
like the same field to reflect the new date.

Is this something that can be easily added? (I know how to add fields, etc,
just do not have a handle on how to automatically enter a date IF and only
if the record is modified.

This is easily done when modifications to the data is made through a form. Just use
the Form's BeforeUpdate event.

Me![Last Modified] = Now() 'Date and time
or
Me![Last Modified] = Date() 'Date Only
 
R

Rick Brandt

Wayne G. Dengel said:
Rick: Pls pardon the ignorance (lack of experience), specifically, how do I
use/enter the procedure you refer to below?
Wayne

Go to Form - Design View
On the Form's Property sheet - Event Tab
Find the BeforeUpdate event and press the build [...] button to the right.
Choose Code Builder from the choices
Once in the code module window enter one of the two statements below.
Close and save.

Me![Last Modified] = Now() 'Date and time
or
Me![Last Modified] = Date() 'Date Only
 
W

Wayne G. Dengel

Rick:

Ok, maybe. Before Update now contains: =[Me]![Last Modified]=Now()
The date that is now to be automatically entered whenever a specified record
is updated, should now be stored in a main table, right? to retain the date
derived from the above, right? If so, how is this specific table field
set up so that the next time the specific record is accessed, the date of
the last access is displayed.

Pardon the continued ignorance. I find myself knowing far less than I give
myself credit for.
Wayne



Rick Brandt said:
Wayne G. Dengel said:
Rick: Pls pardon the ignorance (lack of experience), specifically, how do I
use/enter the procedure you refer to below?
Wayne

Go to Form - Design View
On the Form's Property sheet - Event Tab
Find the BeforeUpdate event and press the build [...] button to the right.
Choose Code Builder from the choices
Once in the code module window enter one of the two statements below.
Close and save.

Me![Last Modified] = Now() 'Date and time
or
Me![Last Modified] = Date() 'Date Only
 
R

Rick Brandt

Wayne G. Dengel said:
Rick:

Ok, maybe. Before Update now contains: =[Me]![Last Modified]=Now()
The date that is now to be automatically entered whenever a specified record
is updated, should now be stored in a main table, right? to retain the date
derived from the above, right? If so, how is this specific table field
set up so that the next time the specific record is accessed, the date of
the last access is displayed.

Pardon the continued ignorance. I find myself knowing far less than I give
myself credit for.
Wayne
Lose the first = sign. The event procedure should simply look like...

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me![Last Modified]=Now()
End Sub

This assumes you have a control on the form or a field in the underlying Recordset
named "[Last Modified]". As long as you do then every time you use the form to
change a record that code will fire off just before the record is saved and a new
DateTime value will be saved in that record. You need do nothing to the design of
the field in the table.

I'm not sure of your last question. Does "last accessed" mean "last modified" or
something else. If this field exists in the table and you bind a control to it on
your form then the user will be able to see it.
 
W

Wayne G. Dengel

Clearly I need to take a class in Access! I have the needed 'routine'
working in another database. I have tried to duplicate what I did there,
back then (2-3 yrs ago), no success! Cannot figure out where the
differences are. Probably should 'hack' away 'til I am successful. (Pardon
the 'hack' but when I am not sure what I am doing, what else does one call
it?)

Wayne Dengel


Rick Brandt said:
Wayne G. Dengel said:
Rick:

Ok, maybe. Before Update now contains: =[Me]![Last Modified]=Now()
The date that is now to be automatically entered whenever a specified record
is updated, should now be stored in a main table, right? to retain the date
derived from the above, right? If so, how is this specific table field
set up so that the next time the specific record is accessed, the date of
the last access is displayed.

Pardon the continued ignorance. I find myself knowing far less than I give
myself credit for.
Wayne
Lose the first = sign. The event procedure should simply look like...

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me![Last Modified]=Now()
End Sub

This assumes you have a control on the form or a field in the underlying Recordset
named "[Last Modified]". As long as you do then every time you use the form to
change a record that code will fire off just before the record is saved and a new
DateTime value will be saved in that record. You need do nothing to the design of
the field in the table.

I'm not sure of your last question. Does "last accessed" mean "last modified" or
something else. If this field exists in the table and you bind a control to it on
your form then the user will be able to see it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top