By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,921 Members | 1,479 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,921 IT Pros & Developers. It's quick & easy.

Populate Date Automatically in Access Form

mmect
P: 6
I'm working on a very basic form and need to know how to add a current date to a field (modified_recommendation) when another field is changed (recommendation). Please let know how i can do this. Currenltly, I have the following code in my database (OnCurrent and AfterUpdate)...the problem i'm having is that the date gets populated after the records is opened + when the code's in the Afterupdate part of the recommendation field, it does work.

Expand|Select|Wrap|Line Numbers
  1. Private Sub recommendation_AfterUpdate()
  2.  
  3.     Me![recommendation_modified] = Now()
  4.  
  5. End Sub
Mar 2 '07 #1
Share this Question
Share on Google+
4 Replies


MSeda
Expert 100+
P: 159
you just need to take the code out of the on current event. the on current event is cause the date to change before any changes are made.
Mar 3 '07 #2

NeoPa
Expert Mod 15k+
P: 31,492
MSeda's absolutely right.
I would add that, unless you do want the time element included in the field, you should use Date() instead of Now().
Mar 5 '07 #3

mmect
P: 6
I changed the code a bit (added Date() and took the code out of On Current) and it worked great. Thanks for your help!
Mar 5 '07 #4

NeoPa
Expert Mod 15k+
P: 31,492
Very pleased to hear it :)
It's impressive how well things can work when an OP follows the instructions exactly (That's a compliment btw ;)).
Nice work MSeda for spotting the main flaw.
And nice avatar to the OP.
Mar 5 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.