473,508 Members | 2,038 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sort records in form problem

759 Contributor
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
4 1619
NeoPa
32,557 Recognized Expert Moderator MVP
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
Mihail
759 Contributor
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
32,557 Recognized Expert Moderator MVP
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
Mihail
759 Contributor
Thank you !
Apr 10 '12 #5

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

Similar topics

4
2643
by: Phil Powell | last post by:
Very simplistic but I am utterly STUMPED at this one. I have a db table "person" that I can sort by title, first_name, last_name, or city with no problems at all because "title", "first_name",...
3
2547
by: Lad | last post by:
What is the best( easiest)way how to sort a file? I have a file where each record consists of 3 fields( 3 words) and I would like to sort records by the first field( word)in each record. Any idea?...
2
13777
by: Max Harvey | last post by:
Hi all, I have a form which is based on a table. The table (table1) has fields like Surname, Firstname, etc. I want to have the form sort by Surname, and then Firstname. I put the Orderby...
12
18977
by: MLH | last post by:
I have created two forms: frmBrowseNegsMainform and frmBrowseNegsSubform. I put a subform control on the first of these. The SourceObject property for the subform control is, of course,...
3
2711
by: srikanth | last post by:
please give me any helpful logics for the subject
3
5929
by: usaccess | last post by:
Hi, I have a form/subform. There is a priority field and then a case status field. I want to display records so that it sorts by case status as "actives" then "on holds" then "completes" and...
17
11683
by: radio1 | last post by:
Configuration: Access 2002 and SQL Server 2000 using a .ADP Project. I would VERY MUCH appreciate anyone's input into this problem I'm having. I have a form in Access that does not permit...
6
2317
by: paulcrowsnest | last post by:
I have a master form (clients), and 2 subforms (invoice and credit account details). This all works great. ive added a command button in the master form (clients) to open a new form as a popup where...
3
6101
by: sail87 | last post by:
I inherited an Access 2003 database and need to change the way a form is sorted. It seems to work like this. There is a table containing work records of work requests. The user fills out a form...
7
2520
by: EManning | last post by:
I have an A2003 database linked to SQL Server 2005. My problem is with a popup form with a filtered table as a recordsource. I set the filter with an SQL statement like this: SELECT * FROM...
0
7226
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7125
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7388
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7049
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5631
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3199
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3186
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1561
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
767
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.