To-day's date updated after any entry

access2010

Registered User.
Local time
Today, 08:37
Joined
Dec 26, 2009
Messages
1,118
Hello.

Could I please receive a suggestion on how to have the field = ResearchDate = updated with to-days date, no matter which field new data has been entered into?

Thank you,
Nicole
 

Attachments

Hi Nicole. Have you tried using the Form's BeforeUpdate event? Just curious...
 
You may also want to try the forms Dirty event. This happens prior to leaving the record.
 
Hi Nicole. Have you tried using the Form's BeforeUpdate event? Just curious...

theDBguy, thank you for the suggestion, how should the = BeforeUpdate = be used?​

Nicole​

You may also want to try the forms Dirty event. This happens prior to leaving the record.

MajP, thank you for the suggestion, how should the = Dirty Event = be used?​

Nicole​

 
In either case your code would be

ResearchDate = Date()

Pick one of the events. Click on the ellipses to create the event procedure. Add the code
 
In either case your code would be

ResearchDate = Date()

Pick one of the events. Click on the ellipses to create the event procedure. Add the code
Majp, thank you for your suggestion, which does not work the way we would like.

This is the code in the date field
Private Sub ResearchDate_LostFocus()
Me.ResearchDate = Date
End Sub

The above code works when the cursor leaves the date field, but I would like to have the DATE updated when the cursor leaves any of the fields.
Do you have a suggestion on how to this?

Crystal
 
Majp, thank you for your suggestion, which does not work the way we would like.

This is the code in the date field
Private Sub ResearchDate_LostFocus()
Me.ResearchDate = Date
End Sub

The above code works when the cursor leaves the date field, but I would like to have the DATE updated when the cursor leaves any of the fields.
Do you have a suggestion on how to this?

Crystal
Did you already try the Form's BeforeUpdate event?
 
Note that nothing is saved until you actually do something to save the current contents. Which is pretty much automatic if you navigate to another record and the form is dirty. But your question was sufficiently unclear for me to not be sure that is what you were thinking to do. Can you be just a little bit more specific about (mechanically) what you want to do in order to make this date get updated? Remembering that if you don't trigger a save, NOTHING gets updated right away.
 
Majp, thank you for your suggestion, which does not work the way we would like.
You will have to explain that because that is the only code that would do what you are saying, unless you are not being clear. This and the before update will do the same thing. The difference is the dirty event will happen without having to leave the record, the before update will do it when you leave the record.

If you want to do this for many fields but not all then build a function.

Public Function SetResearchDate()
me.researchdate = date()
end function

Then for every control you want this to happen, select them all. In the after update property type in
=SetResearchDate()
 
Using the LostFocus event of a Control will update the Record...even if you simply move thru the Control...without making any change!

As suggested...you need to use the Form's BeforeUpdate event. This will only fire if you make a change to any Control:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
  Me.ResearchDate = Date
End Sub
Linq ;0)>
 
Using the LostFocus event of a Control will update the Record...even if you simply move thru the Control...without making any change!
Well, in @MajP 's defense, technically, there wouldn't be any problem. Because if "without making a change" ends up being the case, then the ResearchDate won't be updated either..

Either will work
 
Access 2010, you put the code in the WRONG event. That's why it doesn't work. Use the Form's BeforeUpdate event as theDBGuy suggested. The Form's on Dirty will work but I prefer the Form's BeforeUpdate to keep the date setting with all the form's validation code.
 
Thank you ALL for your suggestions.
I had placed the suggested code in the wrong place and now that the code is in the = BeforeUpdate event = we receive the results wanted.
Crystal
 
Thank you ALL for your suggestions.
I had placed the suggested code in the wrong place and now that the code is in the = BeforeUpdate event = we receive the results wanted.
Crystal
Hi Crystal. Glad to hear you got it sorted out. Good luck with your project.
 

Users who are viewing this thread

Back
Top Bottom