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

How to refresh time on Form's textbox?

100+
P: 111
I have a form which has a textbox called TimeStamp. When we enter a record, it fills current as well as the next record's TimeStamp as the current time. This seems a bit weired. It should fill the time when a person actually starts to enter the record.

Also, sometimes if it takes more than 5 minutes to enter the whole record, in that case the time is still the same as it was when I started to enter the record.
Is there any way we can refresh the time?

Something to be done in Textbox's afterUpdate event may be??

Here is some properties of the textbox,

Default Value:Format(Now(),"Medium Time")
Input Mask: 00:00;
Thanks
Mar 2 '10 #1
Share this Question
Share on Google+
7 Replies


100+
P: 157
You should use one (or more) of the forms events and write VBA

me.text0 = now
Mar 2 '10 #2

100+
P: 111
I tried to put
Me.txtTimeStamp=Format(Now(),"Medium Time")
in forms's AfterUpdate event. It didn't work.
Any other solution??
Mar 2 '10 #3

100+
P: 157
You are almost there.. read the description on the forms events to find an event that suit you. I havent used a bound form for some years so i have forgotten which is right.

Or you could put the code on the other textboxes afterupdate event.
Mar 2 '10 #4

100+
P: 111
OK I got it. I put it under the AfterUpdate event of the other textbox on the same form.
Thanks
Expand|Select|Wrap|Line Numbers
  1. Private Sub Comments_AfterUpdate()
  2. Me.Text42.Value = Format(Now(), "Medium Time")
  3. End Sub
Mar 2 '10 #5

TheSmileyCoder
Expert Mod 100+
P: 2,321
If you want the time recorded to be the time where the record is saved, you should put it in the before_Update event.

Placing it in the After_Update will update the time AFTER you saved your record. This also means that your Dirtying the form again, and that if a user preses esc, or undo, the timestamp wont be saved.


You should also store the full time.
Expand|Select|Wrap|Line Numbers
  1. Me.Text42.Value=Now()
And then set the format of the textbox to only display the part you want.
Mar 2 '10 #6

missinglinq
Expert 2.5K+
P: 3,532
If he was using the Form_AfterUpdate event, you'd be right, Smiley, but he's using the AfterUpdate event of a control on the form, Comments, not the Form_AfterUpdate event.

To record the time the record is saved place the code in the Form_BeforeUpdate event.

Linq ;0)>
Mar 2 '10 #7

100+
P: 111
Thanks for the input guys. I wanted to save the "time" when the user is done with that record. Missinglinq, you are right. When I put the code under Comment_AfterUpdate, it was changing the time as soon as the user is done with only "Comments" textbox. If you put it under Form_BeforeUpdate it will wait until you are "completely" done with that record.
Thanks for the input all you guys!!
Mar 3 '10 #8

Post your reply

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