S
Silvio
The code below will populate an unbounded combo box using the columns
headings of a query. The question I have is: how can I sort the data in the
combo box in ascending order? Right now, it appears that the order to follow
the order on the columns in the query from left to right. For example if the
first column in the query is called Column10, Columns3, Column5 and so on,
my combo box will display
Column10
Column3
Colums5
What I want to see is
Column3
Column5
Column10
Thank you folks.
Dim curDatabase As Object
Dim strColumnsNames As String
Dim qryUsers As Object
Dim fldColumn As Object
' Get a reference to the current database
Set curDatabase = CurrentDb
' Get a reference to a query named qryUsers
Set qryUsers = curDatabase.QueryDefs("qryUsers")
' Retrieve the name of each column of the quary and
' store each name in the strColumnsNames string
For Each fldColumn In qryUsers.Fields
strColumnsNames = strColumnsNames & fldColumn.Name & ";"
Next
' Set the strColumnsNames string as the data source of the combo box
cboColumnNames1.RowSource = strColumnsNames
headings of a query. The question I have is: how can I sort the data in the
combo box in ascending order? Right now, it appears that the order to follow
the order on the columns in the query from left to right. For example if the
first column in the query is called Column10, Columns3, Column5 and so on,
my combo box will display
Column10
Column3
Colums5
What I want to see is
Column3
Column5
Column10
Thank you folks.
Dim curDatabase As Object
Dim strColumnsNames As String
Dim qryUsers As Object
Dim fldColumn As Object
' Get a reference to the current database
Set curDatabase = CurrentDb
' Get a reference to a query named qryUsers
Set qryUsers = curDatabase.QueryDefs("qryUsers")
' Retrieve the name of each column of the quary and
' store each name in the strColumnsNames string
For Each fldColumn In qryUsers.Fields
strColumnsNames = strColumnsNames & fldColumn.Name & ";"
Next
' Set the strColumnsNames string as the data source of the combo box
cboColumnNames1.RowSource = strColumnsNames