copy time to textbox

mykil

My Life is Boring
Local time
Tomorrow, 04:29
Joined
Aug 16, 2011
Messages
117
Hi everyone. Do you know how to copy the time automatically to text box to become time as data (rich text) when entering data to a form. Thanks a lot!!!

:confused:
 
There are many ways to do this. What I recommend is add a Date/Time field called Created to the table, and in design view, set the DefaultValue property of that field to . . .
Code:
=Now()
. . . and whenever a record is added that field will automatically contain the value of the current system date and time.

But there is also a Time() function, which only returns the current time, and you can assign it to the DefaultValue property of the field on the form, or you can set it during the Form's BeforeInsert or AfterInsert events . . .
Code:
Private Sub Form_BeforeInsert(Cancel As Integer)
   Me.tbTimeField = Time()
End Sub
. . . or you can check if it's null and set it during Form_Current() . . .
Code:
Private Sub Form_Current()
   If Not IsDate(me.tbTime) then me.tbTime = Now()
End Sub
hth
 
Thank you for the reply.. It works great.. Thank you very much :cool:
 

Users who are viewing this thread

Back
Top Bottom