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 PopulateListboxWithMallsgi s9Query(aP ath As String, theTable As String, strSQL As String, theComboBoxName As Object, strOptionalPrefix As String)
'ex QueryAccessDBTableFieldInf oIntoCombo Box "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.OpenFro mFile(aPat h, 0)
Set pTable = pFWorkspace.OpenTable(theT able)
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.FindFiel d(FieldNam e1))
theComboBoxName.List(theCo mboBoxName .ListCount - 1, 1) = pRow.Value(pTable.FindFiel d(FieldNam e2))
theComboBoxName.List(theCo mboBoxName .ListCount - 1, 2) = pRow.Value(pTable.FindFiel d(FieldNam e3))
theComboBoxName.List(theCo mboBoxName .ListCount - 1, 3) = pRow.Value(pTable.FindFiel d(FieldNam e4))
theComboBoxName.List(theCo mboBoxName .ListCount - 1, 4) = pRow.Value(pTable.FindFiel d(FieldNam e5))
theComboBoxName.List(theCo mboBoxName .ListCount - 1, 5) = pRow.Value(pTable.FindFiel d(FieldNam e6))
theComboBoxName.List(theCo mboBoxName .ListCount - 1, 6) = pRow.Value(pTable.FindFiel d(FieldNam e7))
theComboBoxName.List(theCo mboBoxName .ListCount - 1, 7) = pRow.Value(pTable.FindFiel d(FieldNam e8))
theComboBoxName.List(theCo mboBoxName .ListCount - 1, 8) = pRow.Value(pTable.FindFiel d(FieldNam e9))
theComboBoxName.List(theCo mboBoxName .ListCount - 1, 9) = pRow.Value(pTable.FindFiel d(FieldNam e10))
'theComboBoxName.List(theC omboBoxNam e.ListCoun t - 1, 10) = pRow.Value(pTable.FindFiel d(FieldNam e11))
'theComboBoxName.List(theC omboBoxNam e.ListCoun t - 1, 11) = pRow.Value(pTable.FindFiel d(FieldNam e12))
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
I was also wondering how do you set the headers?
Public Sub PopulateListboxWithMallsgi
'ex QueryAccessDBTableFieldInf
'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.OpenFro
Set pTable = pFWorkspace.OpenTable(theT
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.FindFiel
theComboBoxName.List(theCo
theComboBoxName.List(theCo
theComboBoxName.List(theCo
theComboBoxName.List(theCo
theComboBoxName.List(theCo
theComboBoxName.List(theCo
theComboBoxName.List(theCo
theComboBoxName.List(theCo
theComboBoxName.List(theCo
'theComboBoxName.List(theC
'theComboBoxName.List(theC
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.