Combo Box Help

Cpar

Registered User.
Local time
Today, 13:32
Joined
Jan 9, 2016
Messages
41
Hi all i am trying to get a recall date on my form to auto populate using a combo box. In my combo box i have a "1 year", "6 Month" and "4 Month" options. When i choose one of those i want it to take the current date and add the appropriate time into the recall date field. Here is my code thus far.


Private Sub Combo1377_AfterUpdate()

If Combo1377 = "1 Year" Then

Me.RecallDate.Value = AddDate(YYYY, 1, Date)


End Sub


Can you guys fine my error and give me tips?
 
Me.RecallDate.Value = DateAdd("y", 1, Date)
 
Arnelgp thanks for your response. I typed that in but that only works if I have one option in my combo box. How do I use that expression if I have a few options in the combo box?

Thanks
 
Private Sub Combo1377_AfterUpdate()
dim var As Variant
dim dt As Date

dt = Date
For each var in Me.Combo1377.ItemsSelected
If Me.Combo1377.ItemData(var) = "1 Year" Then


dt = DateAdd("y", 1, dt)

ElseIf Me.Combo1377.ItemData(var) = "6 Month" Then

dt = DateAdd("m", 6, dt)

ElseIf Me.Combo1377.ItemData(var) = "4 Month" Then

dt = DateAdd("m", 4, dt)

End If

Next
Me.RecallDate.Value = dt
End Sub
 

Users who are viewing this thread

Back
Top Bottom