boss0021 wrote:
Does anyone know how to:
Populate a ComboBox with all the days of the year for 2005
with out doing it manually
You need to write a function for it. Look for the help topic
"RowSourceType Property (User-Defined Function) — Code Argument Values"
Copy the function below into the code module for the form containing the
combo box. This is for 2005 only. Modify it to do different years.
In the combo's RowSource enter
ListDays
(normally where you see ValueList or Table/Query under Data tab.
Function ListDays(fld As Control, id As Variant, row As Variant, col As
Variant, code As Variant) As Variant
Static strRows() As String
Static Entries As Integer
Dim ReturnVal As Variant
Dim datStart As Date
Dim datEnd As Date
Dim datFor As Date
ReturnVal = Null
Select Case code
Case acLBInitialize ' Initialize.
datStart = DateSerial(Year(Date), 1, 1)
datEnd = DateSerial(Year(Date), 12, 31)
For datFor = datStart To datEnd
ReDim Preserve strRows(Entries)
strRows(Entries) = datFor
Entries = Entries + 1
Next
ReturnVal = True
Case acLBOpen ' Open.
ReturnVal = Timer ' Generate unique ID for control.
Case acLBGetRowCount ' Get number of rows.
ReturnVal = Entries
Case acLBGetColumnCount ' Get number of columns.
ReturnVal = 1
Case acLBGetColumnWidth ' Column width.
ReturnVal = -1 ' -1 forces use of default width.
Case acLBGetValue ' Get data.
ReturnVal = strRows(row)
Case acLBEnd ' End.
Erase strRows
End Select
ListDays = ReturnVal
End Function