M
Marc
I have spent way tooo much time trying to make this function work.
I've searched the groups, and read ADH 97, but to no avail. I am
looking to populate a combo box with a two-column list of data, with
the first column being the bound column.
I have set the "Row Source Type" to FillTableOrQueryList, with 2
columns, with set widths.
Following is the code for my callback function. I know that the
"GetRows" function works due to some debug.print statements. However,
otherwise there are no errors, but the list box doesn't fill and the
debug.print statements in the code below never fire. Any help would be
much much appreciated.
The function is called with me.cborawcode.requery after another field
updates.
Function FillTableOrQueryList(ctl As Control, varID As Variant, lngRow
As Long, lngCol As Long, _
intCode As Integer) As Variant
'Callback function ot fill a multirow-multicolumn listbox
Dim varRetval As Variant
Static intRows As Integer
Dim intRcount As Integer
Static aData() As Variant
Const intCols = 2
'On Error GoTo Err_FillList
Select Case intCode
Case acLBInitialize
'Initialization code, obtain number of rows from recordset
intRows = GetRows(aData)
varRetval = (intRows > 0)
Debug.Print "Fillable" & varRetval
Case acLBOpen
'Return a Unique ID code, using the built-in Timer function
varRetval = Timer
Debug.Print "Open" & varRetval
Case acLBGetRowCount
'Return the number of rows
varRetval = intRows
Debug.Print "Rows" & varRetval
Case acLBGetColumnCount
'Return the number of columns
varRetval = intCols
Debug.Print "Columns" & varRetval
Case acLBGetColumnWidth
'Return the column widths. If you return -1 from the call,
Access will use the
'default width for the speicfic column, allowing you to use the
property sheet
'to supply the column widths
Select Case lngCol
Case 0:
varRetval = -1
Case 1:
varRetval = -1
End Select
Debug.Print "Width" & varRetval
Case acLBGetValue
'Return actual data, by returning an element of the array
filled in case acLBInitialize
varRetval = aData(lngRow, lngCol)
Debug.Print "Value " & varRetval
Case acLBEnd
' Clean up (release memory)
Erase aData
End Select
FillTableOrQueryList = varRetval
Exit_FillList:
Exit Function
Err_FillList:
MsgBox Err.Number & " " & Err.Description
Resume Exit_FillList
End Function
I've searched the groups, and read ADH 97, but to no avail. I am
looking to populate a combo box with a two-column list of data, with
the first column being the bound column.
I have set the "Row Source Type" to FillTableOrQueryList, with 2
columns, with set widths.
Following is the code for my callback function. I know that the
"GetRows" function works due to some debug.print statements. However,
otherwise there are no errors, but the list box doesn't fill and the
debug.print statements in the code below never fire. Any help would be
much much appreciated.
The function is called with me.cborawcode.requery after another field
updates.
Function FillTableOrQueryList(ctl As Control, varID As Variant, lngRow
As Long, lngCol As Long, _
intCode As Integer) As Variant
'Callback function ot fill a multirow-multicolumn listbox
Dim varRetval As Variant
Static intRows As Integer
Dim intRcount As Integer
Static aData() As Variant
Const intCols = 2
'On Error GoTo Err_FillList
Select Case intCode
Case acLBInitialize
'Initialization code, obtain number of rows from recordset
intRows = GetRows(aData)
varRetval = (intRows > 0)
Debug.Print "Fillable" & varRetval
Case acLBOpen
'Return a Unique ID code, using the built-in Timer function
varRetval = Timer
Debug.Print "Open" & varRetval
Case acLBGetRowCount
'Return the number of rows
varRetval = intRows
Debug.Print "Rows" & varRetval
Case acLBGetColumnCount
'Return the number of columns
varRetval = intCols
Debug.Print "Columns" & varRetval
Case acLBGetColumnWidth
'Return the column widths. If you return -1 from the call,
Access will use the
'default width for the speicfic column, allowing you to use the
property sheet
'to supply the column widths
Select Case lngCol
Case 0:
varRetval = -1
Case 1:
varRetval = -1
End Select
Debug.Print "Width" & varRetval
Case acLBGetValue
'Return actual data, by returning an element of the array
filled in case acLBInitialize
varRetval = aData(lngRow, lngCol)
Debug.Print "Value " & varRetval
Case acLBEnd
' Clean up (release memory)
Erase aData
End Select
FillTableOrQueryList = varRetval
Exit_FillList:
Exit Function
Err_FillList:
MsgBox Err.Number & " " & Err.Description
Resume Exit_FillList
End Function