Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Column limit in Listbox

Posted on 2004-10-28
4
Medium Priority
?
193 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
Comment
Question by:flfmmqp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 48

Accepted Solution

by:
Mikal613 earned 2000 total points
ID: 12433279
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

610 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