Automatic date entry after any change in the data.

  • Thread starter oliaccount via AccessMonster.com
  • Start date
O

oliaccount via AccessMonster.com

Can someone tell me the code I need to do this on a form? I need to update
the date to the current date after any change in the record.
 
O

Ofer Cohen

The BeforeUpdate event will be activated when any changes made in the form,
in there use the code
Me.[TextBoxName]=Date()

When Date() return the current date.

Note: The problem eith this, if the user type a value in a field and then
change it back to the same value then that event will be triggered anyway.
If there are not so many fields in the form you can check if the values in
the text boxes changed

If Me.[TextBoxName] <> Me.[TextBoxName].OldValue Then
Me.[DateTextBoxName]=Date()
End If
 
J

Jason Lopez

Could you use and AfterUpdate event in the event that the field is triggered
accidentally? I would think then that if you put information in and the
escape out of it, you did not really update anything.

Jason Lopez

Ofer Cohen said:
The BeforeUpdate event will be activated when any changes made in the
form,
in there use the code
Me.[TextBoxName]=Date()

When Date() return the current date.

Note: The problem eith this, if the user type a value in a field and then
change it back to the same value then that event will be triggered anyway.
If there are not so many fields in the form you can check if the values in
the text boxes changed

If Me.[TextBoxName] <> Me.[TextBoxName].OldValue Then
Me.[DateTextBoxName]=Date()
End If
--
Good Luck
BS"D


oliaccount via AccessMonster.com said:
Can someone tell me the code I need to do this on a form? I need to
update
the date to the current date after any change in the record.
 
O

oliaccount via AccessMonster.com

Is there something that could be interfering with this method. I have tried
seavel possible variations on this code and tried using different event
properties, but so far I'm not getting any dates at all. Thanks for your help.


Ofer said:
The BeforeUpdate event will be activated when any changes made in the form,
in there use the code
Me.[TextBoxName]=Date()

When Date() return the current date.

Note: The problem eith this, if the user type a value in a field and then
change it back to the same value then that event will be triggered anyway.
If there are not so many fields in the form you can check if the values in
the text boxes changed

If Me.[TextBoxName] <> Me.[TextBoxName].OldValue Then
Me.[DateTextBoxName]=Date()
End If
Can someone tell me the code I need to do this on a form? I need to update
the date to the current date after any change in the record.
 
O

oliaccount via AccessMonster.com

An update. I put the first code you gave me into the double click event (to
see if it was actually working at all), and got an error message telling me
that the macro "me." doesn't exist. I think if you could clear that up for me,
then this'll work.
 
O

Ofer Cohen

When the cursor located in the property (Before Update, DoubleClick etc)
you'll see a button with three dots on the right, click on it and select code
view.
Between the Sub and Ënd Sub write the code.

when this code written directly in the property it will search for a macro,
and this is why you get an error
 
O

oliaccount via AccessMonster.com

Ah, just being stupid as usual then. Ta.

Ofer said:
When the cursor located in the property (Before Update, DoubleClick etc)
you'll see a button with three dots on the right, click on it and select code
view.
Between the Sub and Ënd Sub write the code.

when this code written directly in the property it will search for a macro,
and this is why you get an error
 
Top