Date into field after cursor leaves (1 Viewer)

access2010

Registered User.
Local time
Today, 06:57
Joined
Dec 26, 2009
Messages
1,019
Hello.
We have a form into which we would like to automatically enter to-days date when the cursor leaves this field.
May I have your suggestion?
Thank you
Nicole
 

Isaac

Lifelong Learner
Local time
Today, 06:57
Joined
Mar 14, 2017
Messages
8,738
Check out the Control's Exit event and/or Lost Focus event
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:57
Joined
Oct 29, 2018
Messages
21,357
Hi. Not sure if this is what you want, but in the LostFocus event, you could try something like:
Code:
Me.ControlName = Date()
Hope that helps...

Edit: Oops, a little slow...
 

Cronk

Registered User.
Local time
Tomorrow, 00:57
Joined
Jul 4, 2013
Messages
2,770
That should also test that text box is blank otherwise the event will update the date to the current date whenever the field exit occurs in the future.

Code:
if len(Me.ControlName & "") <1 then Me.ControlName = Date()
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 21:57
Joined
May 7, 2009
Messages
19,169
add code to the Form's Dirty Event:
Code:
Private Sub Form_Dirty(Cancel As Integer)
    If Len(Me!dateField & "") = 0 Then
        Me!dateField = Now
    End If
End Sub
 

Users who are viewing this thread

Top Bottom