aziz rasul
Active member
- Local time
- Today, 07:44
- Joined
- Jun 26, 2000
- Messages
- 1,935
I've picked up some code from an Access example for setting a combo/list box RowSourceType property.
The function code is listed below....
This particular example uses a combo box and sets the combo box's values to the past five years.
On the property sheet I set the RowSourceType property to the function name (ListYears) and leave the RowSource property blank.
My problem is that I don't understand how the code works! The function seems to be called several times, and the value of the code parameter controls program flow.
What are the other parameters for and where do they come from? Can anyone explain this user-defined function to me?
The function code is listed below....
Code:
Function ListYears(fld As Control, id As Variant, _
row As Variant, col As Variant, code As Variant) _
As Variant
Const intPreviousYears As Integer = 5
Select Case code
Case acLBInitialize ' Initialize.
ListYears = True
Case acLBOpen ' Open.
ListYears = Timer ' Unique ID.
Case acLBGetRowCount ' Get rows.
ListYears = intPreviousYears
Case acLBGetColumnCount ' Get columns.
ListYears = 1
Case acLBGetColumnWidth ' Get column width.
ListYears = -1 ' Use default width.
Case acLBGetValue ' Get the data.
ListYears = Year(Now) - intPreviousYears + row + 1
End Select
End Function
On the property sheet I set the RowSourceType property to the function name (ListYears) and leave the RowSource property blank.
My problem is that I don't understand how the code works! The function seems to be called several times, and the value of the code parameter controls program flow.
What are the other parameters for and where do they come from? Can anyone explain this user-defined function to me?