Enter date automatically when click in box

rkaria

Registered User.
Local time
Today, 02:17
Joined
Nov 19, 2009
Messages
48
Hi All

I have form with thousands of records where users input data

One the boxs is a text box and the user has to enter the date. I would like it so if the user clicks or tabs into the box it will automatically show the current date. But I only want it to show if the user clicks into the text box or tabs I dont want it to automatically show if the user clicks on new record.

Is there a way to do this?

Thanks in advanced
R
 
Use the OnEnter event of the control to set the value.
 
Use the OnEnter event of the control to set the value.

Thank rural Guy, I tried that. I put date() in OnEnter, but I get the error message " Microsoft can not find the object date()"

Is that the wrong code??
 
Me.ControlName = Date()
...using YOUR ControlName of course.
 
make sure you change the format in the date field on your table. Then go "On Enter" and put the following sample code

Option Compare Database
Private Sub Transaction_Date_Enter()
Forms!Names![Transaction Date] = Date()
End Sub

My date field is named Transaction Date and my form name is Names, you can rename accordingly.
Hope this helps you!
 
Last edited:
Now() also includes the current time where Date() has the time set to midnight.
 
thanks guys that worked. How would set this so it only enters the current date if the text box is blank.

Cheers
R
 
If Len(Me.ControlName & "") = 0 Then
Me.ControlName = Date()
End If
...using YOUR ControlName of course.
 

Users who are viewing this thread

Back
Top Bottom