I am attempting to populate a list box by creating a function and placing the function name in the RowSourceType Property of the List Box. The list that I want in the List Box is a Recordset created with a Select Statement.
I am using function format from a help example. The help reference is called "RowSourceType Property (User-Defined Function) - Code Argument Values" and if you click the Example hypertext you will see the example code.
I can’t seem to get it to use my Recordset to populate the List Box. If you know the syntax to accomplish this I would appreciate the help.
Here is the attempted code:
I am using function format from a help example. The help reference is called "RowSourceType Property (User-Defined Function) - Code Argument Values" and if you click the Example hypertext you will see the example code.
I can’t seem to get it to use my Recordset to populate the List Box. If you know the syntax to accomplish this I would appreciate the help.
Here is the attempted code:
Code:
Function ListTempProjNums(fld As Control, id As Variant, row As Variant, col As Variant, code As Variant) As Variant
'Dim rst As Recordset
Select Case code
Case acLBInitialize ' Initialize.
ListTempProjNums = True
Case acLBOpen ' Open.
ListTempProjNums = Timer ' Unique ID.
Case acLBGetRowCount ' Get rows.
ListTempProjNums = -1
Case acLBGetColumnCount ' Get columns.
ListTempProjNums = 1
Case acLBGetColumnWidth ' Get column width.
ListTempProjNums = -1 ' Use default width.
Case acLBGetValue ' Get the data. (Help here!)
Set rst = CurrentDb.OpenRecordset(strSql)
rst.MoveLast
'ListTempProjNums = rst
End Select
End Function
Last edited by a moderator: