'Populate date based on combobox selection

I have two items in ComboBox1, one is Cardio Only and second is Gym Only.
I want to auto populate Renew Date in TextBox8 based on Combobox1 selection.

e.g.
If I select "CARDIO ONLY" then Next Renew date should be 90days + currentdate or 3 months + current date in TextBox8.
If I select "GYM ONLY" then Next Renew date should be 30days + currentdate or 1 month + currentdate in TextBox8.

(in days)
90 + 22/01/2022 = 22/04/2022
30 + 22/01/2022 = 21/02/2022

(in months)
3 + 22/01/2022 = 22/04/2022
1 + 22/01/2022 = 21/02/2022



Solution 1:[1]

Private Sub ComboBox1_Change()

   Dim mth As Long
   Select Case Me.ComboBox1.Value
       Case "GYM ONLY"
           mth = 1
       Case "CARDIO ONLY"
           mth = 3
   End Select
   If mth > 0 Then
       Me.TextBox8 = Format(DateAdd("m", mth, Date), "dd/mm/yyyy")
   End If

End Sub

Solution 2:[2]

Use this to add 3 months to the current date:

DateAdd("m", 3, Date)

this to add 90 days to the current date

DateAdd("d", 90, Date)

Note that adding days and adding months does not always yield the same result, depending on the number of days in the months.

E.g. DateAdd("m", 1, #2002/1/30#) yields 2002/02/28.

But DateAdd("d", 30, #2002/1/30#) yields 2002/03/01.

See also: DateAdd function

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 CDP1802
Solution 2 Olivier Jacot-Descombes