Last Edited

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

We need to add a date field to our tables to record the dates records were
last edited. We currently have a date created field which basically has its
default setting as Now().

The date created field is not displayed on any forms and we dont want the
edited date field to be displayed either. How would I go about
creating/setting its value to the time it was edited?

Ian
 
Make sure the date fields appear in the record set to which the form is
bound, even if the fields don't appear on the form.

In the form's BeforeUpdate event, set the value of the LastUpdated field to
Now.

If you're doing updates without using a form, you're out of luck...
 
Hi thanks for the quick reply. I tried entering

LastUpdated = Now()

But I keep getting a error message saying

Cant find the macro LastUpdated = Now()
 
Do you have a Field named "LastUpdated" in the Form's RecordSource?

Doug referred to a Field "LastUpdated" which needs to come from your Table
and is included in the RecordSource of the Form.

Also, I would use:

Me.LastUpdated

to qualify that LastUpdated is a Field in the RecordSource of the Form (to
be accurate, this refers to a Form Property created automatically by Access
to represent the Field [LastUpdated] in the Form's RecordSource).
 
In addition to what Van's already told you, how did you enter that code?

Hopefully you know that you need to open the form's Property sheet, find the
BeforeUpdate event line on that sheet, select [Event Procedure] from the
combobox associated with the event, click on the ellipses (...) to the right
of that, and type it into the VBA routine that you get put into.
 
Hi,

The form is only based on one table where all the fields including the last
updated come from. The field is listed on the field list on the form as
well.

I tried putting

Me.LastUpdated=Now()

But I had the same message could not find macro Me etc.
Where am I going wrong?

Ian

Van T. Dinh said:
Do you have a Field named "LastUpdated" in the Form's RecordSource?

Doug referred to a Field "LastUpdated" which needs to come from your Table
and is included in the RecordSource of the Form.

Also, I would use:

Me.LastUpdated

to qualify that LastUpdated is a Field in the RecordSource of the Form (to
be accurate, this refers to a Form Property created automatically by Access
to represent the Field [LastUpdated] in the Form's RecordSource).


--
HTH
Van T. Dinh
MVP (Access)



NoviceIan said:
Hi thanks for the quick reply. I tried entering

LastUpdated = Now()

But I keep getting a error message saying
 
Doug diagnosed 100% percent correctly here. It sounds like you typed the
posted code in the "Before Update" row in the Events tab of the Form's
Properties window.

Follow Doug's instructions to construct the Event Procedure (VBA) code and
it should work.
 
Sorry your absolutely right I'm an idiot sorry about that. I put the code in
VB and it works fine now. Good job.

Would this work if information was updated using a query as well?

Many thanks Ian

Douglas J Steele said:
In addition to what Van's already told you, how did you enter that code?

Hopefully you know that you need to open the form's Property sheet, find the
BeforeUpdate event line on that sheet, select [Event Procedure] from the
combobox associated with the event, click on the ellipses (...) to the right
of that, and type it into the VBA routine that you get put into.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


NoviceIan said:
Hi thanks for the quick reply. I tried entering

LastUpdated = Now()

But I keep getting a error message saying

Cant find the macro LastUpdated = Now()
 
You mean a stand-alone query?

You'd need to include code in the query to load Now() into that field as
part of the update or insert.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


NoviceIan said:
Sorry your absolutely right I'm an idiot sorry about that. I put the code in
VB and it works fine now. Good job.

Would this work if information was updated using a query as well?

Many thanks Ian

Douglas J Steele said:
In addition to what Van's already told you, how did you enter that code?

Hopefully you know that you need to open the form's Property sheet, find the
BeforeUpdate event line on that sheet, select [Event Procedure] from the
combobox associated with the event, click on the ellipses (...) to the right
of that, and type it into the VBA routine that you get put into.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


NoviceIan said:
Hi thanks for the quick reply. I tried entering

LastUpdated = Now()

But I keep getting a error message saying

Cant find the macro LastUpdated = Now()

:

Make sure the date fields appear in the record set to which the form is
bound, even if the fields don't appear on the form.

In the form's BeforeUpdate event, set the value of the LastUpdated
field
to
Now.

If you're doing updates without using a form, you're out of luck...

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hi,

We need to add a date field to our tables to record the dates
records
were
last edited. We currently have a date created field which
basically
has
its
default setting as Now().

The date created field is not displayed on any forms and we dont
want
the
edited date field to be displayed either. How would I go about
creating/setting its value to the time it was edited?

Ian
 

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

Back
Top