Hi,
I've written some vba to set a combo box value list as last month or the month before. Now I'm trying to format it & am having issues.
I've set the combo box itself to be mmm yyyy & once a selection is made, it displays like that, but the dropdown is still showing eg 01/02/2011. What do I need to do to get it to show in the dropdown as mmm yyyy while still being set as a date (needed for later)?
This is my code (please don't laugh!!!! I try!):
Dim myDateArray(1) As String, myDateList As String, i As Integer, m As Integer, f As Integer, subi As Integer
If Int(VBA.Year(Now()) / 4) = VBA.Year(Now()) / 4 Then
f = 29
Else
f = 28
End If
For i = 0 To 1
If i = 0 Then
subi = 13
Else
subi = m
End If
m = VBA.Month(Now())
myDateArray(i) = CStr(VBA.DateSerial(VBA.Year(Now()), m, 1) - Choose(subi, 30, 31, 31, f, 31, 30, 31, 30, 31, 31, 30, 31, 0) - Choose(m, 31, 31, f, 31, 30, 31, 30, 31, 31, 30, 31, 30))
Next i
myDateList = Join(myDateArray, ";")
Me!cmbYr.RowSource = myDateList
Thanks
I've written some vba to set a combo box value list as last month or the month before. Now I'm trying to format it & am having issues.
I've set the combo box itself to be mmm yyyy & once a selection is made, it displays like that, but the dropdown is still showing eg 01/02/2011. What do I need to do to get it to show in the dropdown as mmm yyyy while still being set as a date (needed for later)?
This is my code (please don't laugh!!!! I try!):
Dim myDateArray(1) As String, myDateList As String, i As Integer, m As Integer, f As Integer, subi As Integer
If Int(VBA.Year(Now()) / 4) = VBA.Year(Now()) / 4 Then
f = 29
Else
f = 28
End If
For i = 0 To 1
If i = 0 Then
subi = 13
Else
subi = m
End If
m = VBA.Month(Now())
myDateArray(i) = CStr(VBA.DateSerial(VBA.Year(Now()), m, 1) - Choose(subi, 30, 31, 31, f, 31, 30, 31, 30, 31, 31, 30, 31, 0) - Choose(m, 31, 31, f, 31, 30, 31, 30, 31, 31, 30, 31, 30))
Next i
myDateList = Join(myDateArray, ";")
Me!cmbYr.RowSource = myDateList
Thanks