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

Can I record the date that a status field in my table changes

P: 30
I have in my table a field OrderStatus and want to use the now() function or similar to record in a field DateStatusChanged the date and time the status was last changed. How can I do this? and can the code be in the table the data is stored in? or does it need to be in the form that the user is using to change the status?
Jul 17 '07 #1
Share this Question
Share on Google+
5 Replies

Expert 2.5K+
P: 3,532
There is no "code" per se in tables. In the code module for your form:
Expand|Select|Wrap|Line Numbers
  1. Private Sub OrderStatus_BeforeUpdate(Cancel As Integer)
  2. Me.DateStatusChanged = Now
  3. End Sub
Welcome to TheScripts!

Jul 17 '07 #2

P: 30
Thank you:

Expand|Select|Wrap|Line Numbers
  1. Me.DateStatusChanged = Now ()
above code worked just as I wished it to. Being the first time I have used code could you explain
Expand|Select|Wrap|Line Numbers
  1. Me.
(or a website that has a dictionary of code)

Is there similar code that can be used to give a changed date if any part of a record is updated rather than targeting a specific field?
Jul 18 '07 #3

Expert 2.5K+
P: 3,532
Putting the same code in

Private Sub Form_BeforeUpdate(Cancel As Integer)

will timestamp changes made anywhere on the record when the record is saved.

The Me. is a kind of shorthand, if you will, for the name of the current form.
If you're writing code in the code module for a form named


and referring to, say a control on that form named


you could write


or you can simply write


Same thing with, say, requerying the form. Instead of




Linq ;0)>
Jul 18 '07 #4

P: 30
Thank you for answering my question and the further help in understanding it.
Jul 18 '07 #5

Expert 2.5K+
P: 3,532
Glad we could help!

Linq ;0)>
Jul 18 '07 #6

Post your reply

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