expression for date last updated

  • Thread starter Thread starter kari
  • Start date Start date
K

kari

I know you can make the default so when you make a new
record, it automatically enters the current date, but I
can't figure out how to do it for existing records when
the have been updated/edited. Any expressions out there
for this problem?? ANY help would be greatly appreciated.
Thanks,
kari
 
kari,

You will want to use a bit of code for this. Presuming you are working
from a form and presuming you have a field in your table named DateUpdated,
it's as simple as this:

Add a control to your form and bind it to your DateUpdated field. You can
make the control visible or not, as you wish.

In the Before Update event of your form, just insert the following:

Me!DateUpdated = Date()


hth,
 
kari said:
I know you can make the default so when you make a new
record, it automatically enters the current date, but I
can't figure out how to do it for existing records when
the have been updated/edited. Any expressions out there
for this problem?? ANY help would be greatly appreciated.
Thanks,
kari
 
kari said:
I know you can make the default so when you make a new
record, it automatically enters the current date, but I
can't figure out how to do it for existing records when
the have been updated/edited. Any expressions out there
for this problem?? ANY help would be greatly appreciated.
Thanks,
kari
 
I did what you explained, but I think I'm still doing
something wrong. Could you help me out on this?
 
I'd be glad to help, but I'll need some more detail from you.

Are you getting an error message? If so, what is it?

Or is it that you are unsure of how to insert code behind an event? Here's
some detail on how to do that:

Open your form in Design View, then:

1. Press ALT-Enter to open the Property Sheet for the form.

2. You will see another form with a ComboBox at the top which says "Form".
Leave that one alone. Below the ComboBox is a set of Tabs. Click the one
that says "Events".

3. In the grid below, locate the row labeled, Before Update. It should be
blank. Click anywhere in the white space to the right of the label and you
will see a downward-pointing arrow appear, indicating that this is also a
ComboBox. Click the arrow and select "Event Procedure".

4. Then, notice that there is an ellipsis or three little dots (...) to the
right of the ComboBox. Click the ellipsis and you will open a code window.
You will see that Access has given you a space for entering some code in
this event - it will look something like the following:

Private Sub Form_BeforeUpdate(Cancel As Integer)

End Sub

The Before Update event will "fire" just before an Edited Record is saved to
the
database, so you will want to update the DateUpdated field on your form.

5. After the "Private Sub Form_BeforeUpdate(Cancel as Integer)" line,
insert the following code:

me!DateUpdated = Date()

Save the module. Then, click on the Debug menu item in the code window and
select Debug. If the debug produces no errors, just close the module.

hth,
 
I receive a run-time error '2465' Can't find the field
referred to in expression. So I started over and now it's
not working at all!! I'm sorry I'm having a bad day!!
 
Check the following:

1. There should be a field named DateUpdated in your table. DataType for
the field should be Date/Time.

2. There should be a control on your form named DateUpdated. This control
should be bound to your table field DateUpdated; i.e., set the ControlSource
property of the control to DateUpdated.

Let's get those two things out of the way, first. Post back and advise on
the results
 
Back
Top