Date stamp changes

Guy Boswell

Registered User.
Local time
Today, 07:59
Joined
Jul 20, 2009
Messages
26
I want to date stamp a record in a table when a user amends a value via a form.

I have a simple form, frmRiverLevels that displays values from a table tblRiverLevels. The fields are fldTargetArea (text field, linked to another table of places for which I can hold river level information), fldCurrentRiverLevelMessage (text field) and fldMessageDate (date field).

The form is opened from another form which passes the value of the fldTargetArea. I don't want the user to see or change the message of other target areas or set up new target areas from this form. So I have switched off the navigation buttons and they only see the one record.

Only the fldCurrentRiverLevelMessage and an exit button are enabled on the form. Whenever the user has changed the value in this field and presses Enter I want the fldMessageDate to update to Now(), preferably before they hit the exit button so they can see it has changed.

Please can someone help me - I'm getting nowhere fast. What do I put into which event box?

Oh yes, I changed the Enter Key Behaviour for the message to Default instead of New Line in Field but that didn't help.

Thank you very much for your help. Guy
 
you can use the "on change" or any such event depending on exact timing you have to write it into the control using:
Me.YourTableDate = Now()

I hope that is enough ?
 
you want this in the forms beforeupdate event - this is the event immediately before the record is written to the table

a lot of people have fields for

insertedby
insertedon
amendedby
amendedon


so you get

Code:
if me.newrecord then
  insertedby = whatever
  insertedon = whatever
else
  amendedby = whatever
  amendedon = whatever
end if
 
the key is the Before Update event. (i'd be happy to hear about alternatives to this though).

you can update the timestamp when the form closes, but the user won't see the new date. i suppose you can put in the code into a text box as well, but that could result in problems/errors if changes don't want to be saved.

Sub Form_BeforeUpdate
me.fldMessageDate = Now() 'i think the brackets might not be necessary...
End Sub

this will fire only if a change has been made on the form; and will fire if any change has been made.

hth.


Edit: wow i'm slow...
 
Hooray! All works fine. Thank you very much for your help.
 

Users who are viewing this thread

Back
Top Bottom