Can a selection in a combo box trigger today's date to appear in another field? (1 Viewer)

gojets1721

Registered User.
Local time
Today, 07:43
Joined
Jun 11, 2019
Messages
429
I have a form with a combo box (the selections are Yes and No, with the default being No). If yes is selected, is it possible for today's date to be populated in a completely seperate date field?

I can provide an example DB if helpful
 

Minty

AWF VIP
Local time
Today, 14:43
Joined
Jul 26, 2013
Messages
10,355
Yes. In the after update event of the combo

Me.YourDateFieldControl = Date()
 

gojets1721

Registered User.
Local time
Today, 07:43
Joined
Jun 11, 2019
Messages
429
Forgive me. The choices are N/A, No, and Yes (N/A is default). Is there a way to code it so that "yes" is the only selection that triggers the date?
 

isladogs

MVP / VIP
Local time
Today, 14:43
Joined
Jan 14, 2017
Messages
18,186
Yes 😁

Code:
Private Sub ComboName_AfterUpdate()

    If Me.ComboName ="Yes" Then Me.DateFieldControlName=Date()

End Sub
 

CJ_London

Super Moderator
Staff member
Local time
Today, 14:43
Joined
Feb 19, 2013
Messages
16,555
would help if you were consistent in what you tell us

combo box (the selections are Yes and No, with the default being No
The choices are N/A, No, and Yes (N/A is default)

So based on your second version I'm assuming the values are text and not numeric

if me.comboctrl="Yes" Then Me.YourDateFieldControl = Date()

or

Me.YourDateFieldControl = iif(me.comboctrl="Yes",Date(),null)

or

Code:
if me.comboctrl="Yes" Then
    Me.YourDateFieldControl = Date()
else
     Me.YourDateFieldControl = null
end if

depends what you want to happen if the user chooses yes, then changes their mind to no or n/a
 

Users who are viewing this thread

Top Bottom