Record sort on subform

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
 
J

Jeff Boyce

Tony

What is the record source (i.e., the SQL statement) of the subform? Does it
include a sort (i.e., ORDER BY)?
 
G

Guest

One way is to base the subform on a query that is sorted by company name
rather than basing it on a table.
 
B

Brian

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
 
T

Tony Williams

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
 
B

Brian

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.
 

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