Solved

Column limit in Listbox

Posted on 2004-10-28
176 Views
Last Modified: 2008-02-01
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
0
Question by:flfmmqp
    1 Comment
     
    LVL 48

    Accepted Solution

    by:
    There is a 10 column limit

    ColumnCount

    The first Property we will change is the ColumnCount, by default this will be 1. Change this to -1. Setting ColumnCount to 0 displays zero columns, and setting it to -1 displays all the available columns. For an unbound data source, there is a 10-column limit (0 to 9).

    http://www.ozgrid.com/News/FillHandListBox.htm
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
    I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

    846 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now