Sorting in a subform

  • Thread starter Thread starter DebbieG
  • Start date Start date
D

DebbieG

My subform is based on a table. One field is SSN which I have made a
combobox in order to see the name. I added a textbox (called ShowName)
whose Control Source shows the name from the combobox. Everything works
great.

However ... the records showing in the subform are in the order they were
entered into the table. I've tried putting me.orderbyon=true and
me.orderby=ShowName.value in various different places but it doesn't work.

Is there a special way to sort a subform based on a control that isn't a
field from the table? If there is, where would I put it?

Thanks,
Debbie
 
I don't think you can. The field has to be in the table
in order to sort by it. You should be able to join the
subform table to whatever table has the name, and then
sort on the name. That SHOULD keep the subform updateable.


Chris
 
DebbieG said:
My subform is based on a table. One field is SSN which I have made a
combobox in order to see the name. I added a textbox (called ShowName)
whose Control Source shows the name from the combobox. Everything works
great.

However ... the records showing in the subform are in the order they were
entered into the table. I've tried putting me.orderbyon=true and
me.orderby=ShowName.value in various different places but it doesn't work.

Is there a special way to sort a subform based on a control that isn't a
field from the table? If there is, where would I put it?

You can only sort on a field in the form's record source
query. (I.e. you can not sort on a control's value).

Create a query based on your table and add the combo box's
row source table to the query. Make sure the line
connecting the two table has the ssn field at both ends, and
drag the name field down to the field list. Use the query
as the form's record source.
 
That did it. Now, why didn't I think of that in the first place? I get so
involved in this that I can't think of the simplest things!
Thanks!


I don't think you can. The field has to be in the table
in order to sort by it. You should be able to join the
subform table to whatever table has the name, and then
sort on the name. That SHOULD keep the subform updateable.


Chris
 
Debbie-
I'm no expert on this, but what I have done in the past is
create a query that shows all of the records in the table
and you can use the sort ascending or descending option in
one or more colomun(s). Use the query as the record
source instead of the table itself.

Good luck.
 
Back
Top