vsprogrammer
Programmer
Hi! I have a combo in VB6 that I have to populate with more than one column. I am therefore using a TDBlist in which I want it to populate with four columns. Following is what I have in my code:
When I step throught the code to see what each column will give me, ?cboClientDistrict.Columns(2).Value in the immediate window gives me a script out of range. If is fine for .columns(0) and (1), however, for (2) and (3) I get the error. Wondering if anyone could point me in the right direction? Thanks a bunch in advance! Vicky
Code:
Public Sub PopulateTDBComboClientDistrict(ByRef cboTmpClientDistrict As Object)
Dim xTemp As New XArrayDB
Dim intSelectedRow As Integer
Dim row As Integer
Dim rsClientDistrict As ADODB.Recordset
Dim mstrsql As String
mstrsql = "SELECT ClientDistrictdesc, Clientdistrictdefinition, ClientDistrictCode, ClientDistrictCodeTableSeq FROM ClientDistrictCodeTable " & _ " ORDER BY ClientDistrictdesc "
Set rsClientDistrict = adoCN.OpenResultSet(mstrsql, adOpenStatic, adLockReadOnly)
cboTmpClientDistrict.Clear
cboTmpClientDistrict.ReBind
cboTmpClientDistrict.Text = ""
xTemp.Clear
If Not rsClientDistrict.EOF Then
'Allocate space for 4 columns and the number
'of rows return by resultset rsGrid
' xTemp.ReDim 0, rsClientDistrict.RecordCount - 0, 0, rsClientDistrict.Fields.count - 0
xTemp.ReDim 1, rsClientDistrict.RecordCount - 1, 0, rsClientDistrict.Fields.count - 1
'0 - Lower bound for row, intNumberRows - Upper bound for row
'0 - Lower bound for column, 4 - Upper bound for column
'The LowerBound and UpperBound properties correspond
'to the LBound and UBound functions in Visual Basic.
'Hard-coded dimensions can be used instead, if known.
For row = xTemp.LowerBound(1) To xTemp.UpperBound(1)
If Not rsClientDistrict.EOF Then
xTemp(row, 0) = CStr(rsClientDistrict(0)) & "" ' ClientDistrictdesc
xTemp(row, 1) = rsClientDistrict(1) & "" ' Clientdistrictdefinition
xTemp(row, 2) = rsClientDistrict(2) & "" ' ClientDistrictCode
xTemp(row, 3) = rsClientDistrict(3) & "" ' ClientDistrictCodeTableSeq
If Not rsClientDistrict.EOF Then rsClientDistrict.MoveNext
End If
Next row
End If
Set cboTmpClientDistrict.Array = xTemp
cboTmpClientDistrict.ReBind
cboTmpClientDistrict.Refresh
cboTmpClientDistrict.SelectedItem = intSelectedRow
End Sub
When I step throught the code to see what each column will give me, ?cboClientDistrict.Columns(2).Value in the immediate window gives me a script out of range. If is fine for .columns(0) and (1), however, for (2) and (3) I get the error. Wondering if anyone could point me in the right direction? Thanks a bunch in advance! Vicky