By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,490 Members | 1,223 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,490 IT Pros & Developers. It's quick & easy.

Sort records in form problem

100+
P: 759
Hello !

I have 2 tables:
Expand|Select|Wrap|Line Numbers
  1. tblParents:
  2.     ID_Parent (autonumber)
  3.     ParentName (Text)
Expand|Select|Wrap|Line Numbers
  1. tblChilds:
  2.     ID_Child (autonumber)
  3.     ID_Parent (Look Up field on tblParents)
  4.     ChildName
and one form, frmChilds, bound to tblChilds
In this form, a combo box (named ID_Parent)
The Row Source is:
Expand|Select|Wrap|Line Numbers
  1. SELECT [tblParents].[ID_Parent], [tblParents].[ParentName] FROM tblParents ORDER BY [ParentName]; 
and the Control Source is ID_Parent

The question is:
How to open this form and have sorted it's records by ParentName by default ?

Thank you !
Apr 7 '12 #1

✓ answered by NeoPa

Yes (almost).

The solution is to bind the two tables together in a query. Custom SQL is also a query (which is technically different from a QueryDef - which is an Access Saved Query object). When I said you need to link the tables together, I meant to link them within a query (using a JOIN statement). The resultant query, whether QueryDef or custom SQL, would be the record source of the form.

Share this Question
Share on Google+
4 Replies


NeoPa
Expert Mod 15k+
P: 31,186
If the form is for [tblChilds], but the sort order required is for [ParentName] (in [tblParents]), then you need to base the form on a record source that includes [ParentName]. IE. You need to link the two tables together (on [ID_Parent]) and use the result for the Record Source of the form.
Apr 8 '12 #2

100+
P: 759
The tables are linked as you say. ID_Parent is a FK in tblChilds.
You say that the solution is to bound the form to a query (or use custom SQL as the Record Source) ?

Thank you for reply !
Apr 9 '12 #3

NeoPa
Expert Mod 15k+
P: 31,186
Yes (almost).

The solution is to bind the two tables together in a query. Custom SQL is also a query (which is technically different from a QueryDef - which is an Access Saved Query object). When I said you need to link the tables together, I meant to link them within a query (using a JOIN statement). The resultant query, whether QueryDef or custom SQL, would be the record source of the form.
Apr 10 '12 #4

100+
P: 759
Thank you !
Apr 10 '12 #5

Post your reply

Sign in to post your reply or Sign up for a free account.