Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Last Updated coding?

Status
Not open for further replies.

onemiland

Programmer
May 29, 2004
18
US
I kept reading about Triggers and what I'm trying to do is I want a date change everytime I update a record so I know when the record has been updated.

Help?

Thanks
 
In the before update event of the form, add some code that adds the timestamp to your control bound to a date/time field in the underlying recordsource:

[tt]me("txtModified").value=now[/tt]

Access doesn't support triggers, form events are the closest one gets;-)

Roy-Vidar
 
Thanks and that did work. But... :) But the date won't show up unless I actually save the record.
Anyway to fix that? save when Tab is hit?
 
Oh - so you need it visible too.

Ok - the method above is often used when you have a hidden control on the form, and ensures there's no changes to the current record just by entering/viewing it.

Using techniques where a control is updatet only by tabbing thru has it's downsides

* if a user only clicks on those controls they want to update, the date will not be updated
* if a user only tabs thru the current record, or accidently clicks into this control, the date will be updated

Some events to try:
* on dirty event of the form - when a change is made
* in the on exit/on lost focus of the control

But, I think I'd keep one control unbound (the one for display puproses), and have a bound control invisible, to be updated by the forms before update event. Then populate the unbound control in the on current, and alter it in either the forms on dirty, or the other method described above, but that's just my view;-)

Roy-Vidar
 
I'm going for On Dirty because I'm the only one entering data and everybody else gets a copy that can't be edited.

Thanks for your help.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top