combo box to show 6 MonthName from September (1 Viewer)

Ksabai

Registered User.
Local time
Today, 01:40
Joined
Jul 31, 2017
Messages
104
I Have written the Following Code:

Private Sub Form_Activate()

Dim x As Integer
Dim m As Integer
m = Month(Date)
With Me.cmbShip01
Me.cmbShip01.Value = Null
For x = m To 12
.AddItem MonthName(x)
Next
End With
End Sub

This Populates Month Names from the Current Month Till December or MonthName(12)

What i want is to Show only Six Months from current Month i.e from September 2019 i want to show Till March 2020.

Can Anyone Help
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 04:40
Joined
May 21, 2018
Messages
8,529
Code:
Public Sub testExists()
   Dim x As Integer
   Dim dtmDate As Date
   dtmDate = Date
   For x = 1 To 12
     Debug.Print Format(DateAdd("m", x, dtmDate), "MMM YYYY")
   Next x
End Sub
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 04:40
Joined
May 21, 2018
Messages
8,529
Code:
 For x = 0 To 11
Probably want the current month included.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 04:40
Joined
May 21, 2018
Messages
8,529
One thing to note. DateAdd will not return an invalid date. So if I add a month to today
1/30/2019 it returns 2/28/2019 and not 2/30/2019.
 

Ksabai

Registered User.
Local time
Today, 01:40
Joined
Jul 31, 2017
Messages
104
Yes it Worked


Just Finished the Work


Thanks Everyone
 

Users who are viewing this thread

Top Bottom