Record sort on subform

  • Thread starter Thread starter Tony Williams
  • Start date Start date
T

Tony Williams

I have a subform based on a table tblmaintabs and it has a control
txtcompany. I want the records when viewed on the subform to be sorted by
txtcompany and in the Order by properties of the subform I have got
tblmaintabs.txtcompany However when I view the form the records aren't
sorted by company, eg the first record starts with the letter "V" and not
"A" and I know there are companies with the letter "A" as the first letter
of their name. Can anyone help?
TIA
Tony Williams
 
Tony

What is the record source (i.e., the SQL statement) of the subform? Does it
include a sort (i.e., ORDER BY)?
 
One way is to base the subform on a query that is sorted by company name
rather than basing it on a table.
 
Tony Williams said:
I have a subform based on a table tblmaintabs and it has a control
txtcompany. I want the records when viewed on the subform to be sorted by
txtcompany and in the Order by properties of the subform I have got
tblmaintabs.txtcompany However when I view the form the records aren't
sorted by company, eg the first record starts with the letter "V" and not
"A" and I know there are companies with the letter "A" as the first letter
of their name. Can anyone help?
TIA
Tony Williams

The OrderBy property is only applied when the form's OrderByOn property is
set to True. You can only do this in VBA code or by choosing Sort from the
menu.

If you the form always to open with the data sorted a certain way, the most
reliable way is to do it is in the form's RecordSource i.e.

SELECT * FROM tblMainTabs ORDER BY company
 
Thanks Bruce. Would I be able to use the form to add records. I thought
that they had to be based on tables for that?
Tony
 
Tony Williams said:
Thanks Bruce. Would I be able to use the form to add records. I thought
that they had to be based on tables for that?
Tony

Not at all. Many/most queries will work just fine, so long as they select
from just one table. See my other reply.
 
Back
Top