Sorting a Combo box

C

CMB

I have a combo box on a form to use to look up records in a table. I
thought it would sort alphabetically by the field I chose, or by the sort
order of the form. How do I define the sort order?

Thank you!
 
A

Allen Browne

The Row Source property of the combo can be a query that sorts it any way
you want.
 
C

CMB

I am not quite getting what I was looking for yet.....

I was using the "wizard" and this is the statement being built:

SELECT [Students 05-06].[StudentID], [Students 05-06].[FamilyID] FROM
[Students 05-06];

The sort I want is by FamilyID. It seems to be adding in StudentID on its
own. Student ID is an autonumbered field in the table, It returns a record,
but the sort is not by ascending FamilyID.

If I try and base the combo box just on a query of ascending FamilyID, it
does not return a record when I select a specific familyID...

Thanks for your help.
 
G

Guest

Hi CMD--You need an ORDER BY clause in your statement:

SELECT [Students 05-06].[StudentID], [Students 05-06].[FamilyID] FROM
[Students 05-06] ORDER BY [Students 05-06].[FamilyID] ASC;


CMB said:
I am not quite getting what I was looking for yet.....

I was using the "wizard" and this is the statement being built:

SELECT [Students 05-06].[StudentID], [Students 05-06].[FamilyID] FROM
[Students 05-06];

The sort I want is by FamilyID. It seems to be adding in StudentID on its
own. Student ID is an autonumbered field in the table, It returns a record,
but the sort is not by ascending FamilyID.

If I try and base the combo box just on a query of ascending FamilyID, it
does not return a record when I select a specific familyID...

Thanks for your help.

Allen Browne said:
The Row Source property of the combo can be a query that sorts it any way
you want.
 
C

CMB

That works great! Thank you.
xRoachx said:
Hi CMD--You need an ORDER BY clause in your statement:

SELECT [Students 05-06].[StudentID], [Students 05-06].[FamilyID] FROM
[Students 05-06] ORDER BY [Students 05-06].[FamilyID] ASC;


CMB said:
I am not quite getting what I was looking for yet.....

I was using the "wizard" and this is the statement being built:

SELECT [Students 05-06].[StudentID], [Students 05-06].[FamilyID] FROM
[Students 05-06];

The sort I want is by FamilyID. It seems to be adding in StudentID on
its
own. Student ID is an autonumbered field in the table, It returns a
record,
but the sort is not by ascending FamilyID.

If I try and base the combo box just on a query of ascending FamilyID, it
does not return a record when I select a specific familyID...

Thanks for your help.

Allen Browne said:
The Row Source property of the combo can be a query that sorts it any
way
you want.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

I have a combo box on a form to use to look up records in a table. I
thought it would sort alphabetically by the field I chose, or by the
sort
order of the form. How do I define the sort order?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top