Sort Records In Form

G

Guest

I have a multi-record form with one combo box that updates a table with one
field. The combo box has 2 columns. Column(0) is the empno and is the bound
column and is not shown. Column(1) is the employee name.

I would like to sort the records by the name from column(1) for the
combobox. As is it now, it sorts by empno column, the bound column. Is this
possible?

Thanks.
 
F

fredg

I have a multi-record form with one combo box that updates a table with one
field. The combo box has 2 columns. Column(0) is the empno and is the bound
column and is not shown. Column(1) is the employee name.

I would like to sort the records by the name from column(1) for the
combobox. As is it now, it sorts by empno column, the bound column. Is this
possible?

Thanks.

Set the RowSource property of the combo box to:

Select TableName.EmpNo, TableName.EmployeeName From TableName Order By
TableName.EmployeeName;

Change the table and field names to whatever your actual table and
field names are.

You might want to add at least one other employee identifier field to
the combo box, i.e. Department, DateOfHire, etc., as it is not
uncommon to have more than one employee with the same name, and you
will need to differentiate between them.
 
G

Guest

If I understand correctly, you're telling me how to sort the records in the
combobox. I want to sort the records of the form, not the records in the
combobox.

Thanks
 
F

fredg

If I understand correctly, you're telling me how to sort the records in the
combobox. I want to sort the records of the form, not the records in the
combobox.

Thanks

You're right. I did tell you how to sort the combo box.
However your message is still confusing.

One does not sort the records in a form by the value of someone
selected in a combo box. One sorts the records in a form by Field, not
the values in the field.
So if you wish to sort the form by Employee Name, you would click on
the EmployeeName field and press the A-Z or Z-A tool button.

Now perhaps you mean to "Filter" the records in the form by selecting
a value in the combo box. But that certainly isn't clear from your
message (at least to me).
 
G

Guest

Sorry to be confusing. I press the A-Z or Z-A tool button and then looked
at the properties for OrderBy. I copied it and set in in the form.open
event. It worked. Thanks.
 

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

Top