Sorting on Text from a Combo Box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Ok, I've poured over the discussion groups and haven't find exactly what I'm
looking for (although I did learn some other stuff I'll need later-so, a big
Thank You to you all!).

I've got a Combo Box (SELECT tblMeds.MedID, tblMeds.MedName FROM tblMeds
ORDER BY tblMeds.MedName;) on a form. When I try to sort the form by MedName
(which is what shows up in the text box), it sorts by MedID instead, which is
understandable, but not what we need. I know there's a fix, but I'll be
jiggered if I can figure it out. Any help would be greatly appreciated.

Thanks in advance!

-Rich F
 
I would guess that the Bound Column of the combo box is set to 1. This will
be the value of the combo box, not the text that is displayed.

What are you doing to sort the form? If you're placing the cursor in the
combo box and pressing the sort button on the toolbar, I show that will sort
on the displayed text. Is the combo box bound to a field? What version of
Access are you using? Are you sorting or filtering?
 
So sorry. Yup, Bound Column is set to 1 and I'm trying to sort via a button
on the form (I'm trying to avoid using the toolbars because the user finds
them "too distracting and cluttered"). Combo box is bound to a field. I am
using 2003 and am most definitely "sorting."

Thank you for the quick attention, Wayne! I've found your posts to be spot
on in the past.
 
To sort via a button on the form, are you using the Click event to set the
form's Sort property? If so, instead of setting it to the value of the combo
box, set it to the Column property of the combo box, referring to the
desired column.

Another option, when doing this in Northwind, the Order By property for the
form gets set to "Lookup_EmployeeID.Salesperson". The Row Source query is
"SELECT DISTINCT Employees.EmployeeID, [LastName] & ", " & [FirstName] AS
Salesperson FROM Employees ORDER BY [LastName] & ", " & [FirstName];".
Judging by that, it appears that if you use

Lookup_NameOfCombo.NameOfField

for the Order By, that you may get what you want.
 
Wayne,

Thank you, thank you, thank you! Your suggestion referring to the column in
the combo box worked perfectly!

Again, thank you for the speedy repsonse and if you're ever in L.A., I owe
you a beer!

--
Rich F


Wayne Morgan said:
To sort via a button on the form, are you using the Click event to set the
form's Sort property? If so, instead of setting it to the value of the combo
box, set it to the Column property of the combo box, referring to the
desired column.

Another option, when doing this in Northwind, the Order By property for the
form gets set to "Lookup_EmployeeID.Salesperson". The Row Source query is
"SELECT DISTINCT Employees.EmployeeID, [LastName] & ", " & [FirstName] AS
Salesperson FROM Employees ORDER BY [LastName] & ", " & [FirstName];".
Judging by that, it appears that if you use

Lookup_NameOfCombo.NameOfField

for the Order By, that you may get what you want.
 
Back
Top