RE: Sort unbonded combo box data

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Mike I need to do this programmatically. The Combo Box list is populated by
the colums headings not the actual records.

"MikeJohnB" wrote:

The Control Source for the unbound Combo Box is a SQL Query. With the form in
design view, select the combo box and then its properties. Select the Row
Source and click on the three dots ... to the right of that property. A Query
will popup in design mode. Drag the columns into the order you want to see
them in. Close and save the query and adjust the size of the columns if
necessary.

I think that will give you the order you want??????

Let me know.

Regards

Mike B
--
Advice to Posters.
Check your post for replies or request for more information.
Consider providing some feed back to the response you have recieved.
Kindest Regards Mike B


"Silvio" wrote:

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

.



Relevant Pages

  • Re: Sort unbonded combo box data
    ... the order on the columns in the query from left to right. ... Dim strColumnsNames As String ... ' Set the strColumnsNames string as the data source of the combo box ...
    (microsoft.public.access.forms)
  • Sort data in unbounded combo box
    ... the columns in the query from left to right. ... Dim strColumnsNames As String ... ' Get a reference to a query named qryUsers ... ' Set the strColumnsNames string as the data source of the combo box ...
    (microsoft.public.access.forms)
  • Sort unbonded combo box data
    ... the order on the columns in the query from left to right. ... Dim strColumnsNames As String ... ' Get a reference to a query named qryUsers ... ' Set the strColumnsNames string as the data source of the combo box ...
    (microsoft.public.access.forms)
  • RE: Sort unbonded combo box data
    ... The Control Source for the unbound Combo Box is a SQL Query. ... design view, select the combo box and then its properties. ... Dim strColumnsNames As String ... ' Set the strColumnsNames string as the data source of the combo box ...
    (microsoft.public.access.forms)
  • RE: Breaking down imported information
    ... Single-record append query: ... ' Check if at EOF of Recordset (rsDataViaCode) ... ' if at EOF Exit Do. ... Dim rsDataViaCode As DAO.Recordset ...
    (microsoft.public.access.modulesdaovba)