how to order a sub form (1 Viewer)

Jackske

Registered User.
Local time
Today, 08:43
Joined
Feb 28, 2000
Messages
48
I have a form (Members of the club), linked to a sub form (payments of membership).

When I open the record of Mr John, I want to see all his payments order by date of payment.

How do I do?

Thanks in advance,

Jackske - Belgium
:confused:
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 00:43
Joined
Feb 28, 2001
Messages
27,222
The sub-form is a form. (No, I'm not being off-handed here.) It has all the abilities of any other form. Including an implied order of reporting.

So you can open the form directly outside the context of the form that calls it. And you can set an OrderBy on the form when in that context. Save it that way. You would never USE it directly because it doesn't yet have the filter for the person in question. You would get payments in date order for all persons, which would be a mess to look at. But you wouldn't open the form directly that often anyway.

Once you establish the order, when you open the form in the context of a Subform, the fields on the sub-form control (which is part of the parent form) still limit the fields you retrieve - but the order specified in the subform itself (the thing that occupies the sub-form control) will be the order you specified separately as I described earlier.

In other words, you specify the FILTER by the properties of the sub-form control on the parent form. But you specify the ORDER on the actual subform that fills the sub-form control.
 

Jackske

Registered User.
Local time
Today, 08:43
Joined
Feb 28, 2000
Messages
48
strange result

Dear Doc_Man,

Thanks for your good will but I did not solve my problem.
I did put a filter in the properties of my form (MemberNr=320) and I did put an order in the properties of my sub-form (OrderBy = date_of_payement).
The strange thing is that when I open my form, I get the record of Member 320 but the payments are NOT order by date_of_payement. If I switch of design mode and directly again to form view; everything is perfect. The payments of Member 320 are order by date_of_payement.
Strange no?
 

Jackske

Registered User.
Local time
Today, 08:43
Joined
Feb 28, 2000
Messages
48
I did find on a google forum the solution of my problem.
You have to define all in the main form.
Here is the solution

Set the OrderBy (and set OrderByOn to true) for the subform in the
OnOpen or OnCurrent event of the main form. Something like:


Me![name of subform control].form.OrderBy = "field you want to sort on"
Me![name of subform control].form.OrderByOn = True
 

godofhell

Database Guru
Local time
Yesterday, 22:43
Joined
May 20, 2005
Messages
180
Jackske, if your form was using a query as its source you could simply set the Sorting in the query and everything would have been fine, no need to code it in.
 
D

driftin

Guest
Subform Sort Issues

What settings need to be made to the Main form if you use a query for the sub-form and the order is set in the query?

I have a subform with a query as the recordsource and it sorts properly when opened as stand alone. but when it is opened as a sub-form within the main form it sorts by (linked) field.

Any thoughts on this?
 

Users who are viewing this thread

Top Bottom