Link to home
Start Free TrialLog in
Avatar of flfmmqp
flfmmqp

asked on

Column limit in Listbox

I am using a program called Arcview which is built on VBA.  Below is the code I am using to put data into a list box.  Whenever I get above column 9 it does not work.  I have columncount set to 12.  Can you only have up to 10 column's?  I even set the last two columns to the same as another column that I know is working "1999".

I was also wondering how do you set the headers?


Public Sub PopulateListboxWithMallsgis9Query(aPath As String, theTable As String, strSQL As String, theComboBoxName As Object, strOptionalPrefix As String)
'ex QueryAccessDBTableFieldInfoIntoComboBox "R:\Monthly Sales Application\Monthly Sales.mdb", "ArcMap_Monthly_Open", "StoreName", "DivisionName = " & strDivision & "", cmbChooseStore
'Using an Sql query grab a table or Query from Access and fill in a combo Box
On Error GoTo ErrorMessage
Dim pQueryDef As IQueryDef
Dim pRow As IRow
Dim pCursor As ICursor
Dim pFeatureWorkSpace As IFeatureWorkspace
Dim pDataset As IDataset
Dim pTable As ITable
Dim pFWorkSpaceFactory As IWorkspaceFactory
Dim pFWorkspace As IFeatureWorkspace
Dim sFieldName As String '*
Set pFWorkSpaceFactory = New AccessWorkspaceFactory


' Open database and table

Set pFWorkspace = pFWorkSpaceFactory.OpenFromFile(aPath, 0)
Set pTable = pFWorkspace.OpenTable(theTable)
Set pDataset = pTable
Set pFWorkspace = pDataset.Workspace
Dim pQueryFilter As IQueryFilter
' Set up first Querydef

Set pQueryDef = pFWorkspace.CreateQueryDef
FieldName1 = "Store Name"
FieldName2 = "Division Name"
FieldName3 = "2004"
FieldName4 = "2003"
FieldName5 = "2002"
FieldName6 = "2001"
FieldName7 = "2000"
FieldName8 = "1999"
FieldName9 = "1998"
FieldName10 = "1999"
FieldName11 = "1999"
FieldName12 = "1999"

With pQueryDef
    .Tables = pDataset.Name
    .WhereClause = strSQL
    Set pCursor = .Evaluate
End With

Set pRow = pCursor.NextRow
Do Until pRow Is Nothing
x = x + 1

    'lstMall.RowSource

    theComboBoxName.AddItem pRow.Value(pTable.FindField(FieldName1))
    theComboBoxName.List(theComboBoxName.ListCount - 1, 1) = pRow.Value(pTable.FindField(FieldName2))
    theComboBoxName.List(theComboBoxName.ListCount - 1, 2) = pRow.Value(pTable.FindField(FieldName3))
    theComboBoxName.List(theComboBoxName.ListCount - 1, 3) = pRow.Value(pTable.FindField(FieldName4))
    theComboBoxName.List(theComboBoxName.ListCount - 1, 4) = pRow.Value(pTable.FindField(FieldName5))
    theComboBoxName.List(theComboBoxName.ListCount - 1, 5) = pRow.Value(pTable.FindField(FieldName6))
    theComboBoxName.List(theComboBoxName.ListCount - 1, 6) = pRow.Value(pTable.FindField(FieldName7))
    theComboBoxName.List(theComboBoxName.ListCount - 1, 7) = pRow.Value(pTable.FindField(FieldName8))
    theComboBoxName.List(theComboBoxName.ListCount - 1, 8) = pRow.Value(pTable.FindField(FieldName9))
    theComboBoxName.List(theComboBoxName.ListCount - 1, 9) = pRow.Value(pTable.FindField(FieldName10))
    'theComboBoxName.List(theComboBoxName.ListCount - 1, 10) = pRow.Value(pTable.FindField(FieldName11))
    'theComboBoxName.List(theComboBoxName.ListCount - 1, 11) = pRow.Value(pTable.FindField(FieldName12))
Set pRow = pCursor.NextRow
Loop


Exit Sub
ErrorMessage:
Dim strError As Integer
strError = Err.Number
 If strError = "6" Then
    MsgBox "You have null values and you cannot have those in the database " & aPath & " table " & theTable
 End If

MsgBox Err.Number & " : " & vbCrLf & Err.Description


End Sub
ASKER CERTIFIED SOLUTION
Avatar of Mikal613
Mikal613
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial