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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Best Event For Record Update

Status
Not open for further replies.

TimTang

Technical User
Jun 24, 2002
132
TH
Hi All,

I've got a date field in a form which indicates the last time a record was updated. I'm currently updating it manually but I want to automate it. I've already written the code and it works; I just need the best place to put it.

I don't want the date to change if your just looking at a record, but I do want it to change if there are any updates to the record. Also I don't want it to change for every field; just once.

What would be the best event to place my code into to accomplish this.

Cheers
 
How are ya TimTang . . .

The forms [blue]Before Update[/blue] event occurs just before a record is saved, and isn't triggered unless the current record has been edited (Dirty property = True). The [blue]Before Update[/blue] allows you to [blue]undo record changes[/blue] (maybe you edited the wrong record!)

[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Thanks to everyone.

It almost works but if I put the code into BeforeUpdate
I start getting this error:

"Update or CancelUpdate without AddNew or Edit Error"

How do I get rid of that?

Cheers!!
 
TimTang . . .

If your updating to the current date, then all you need is:
Code:
[blue]Private Sub Form_BeforeUpdate(Cancel As Integer)
   Me![[purple][B][I]DateFieldName[/I][/B][/purple]] = Date
End Sub[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Thanks TheAceMan1!

I'll try that as soon as I can get back into my database.

I got the "Hide Access container window" to work so well that now I can't get back in!

I tried the hold-shift but it doesn't seem to work.

Oops! Cancel that; it just worked.

Cheers!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top