Sort

  • Thread starter Thread starter Chappie2
  • Start date Start date
C

Chappie2

I have defined an on click action in button on a form as
follows:

DoCmd.OpenReport stDocName, acViewPreview, , Forms!
frmMyForm.Filter

This opens the report with the records selected by the
user through the Filter by Form feature. How do I go
about getting the sort order in the report to match the
dsiplay order set by the user using the sort buttons on
the toolbar in the form?

thanks,

Lloyd
 
Hi Lloyd

In your Report_Open event procedure, set the OrderBy property of the report
to the same as that of the form:

With Forms![YourForm]
If .OrderByOn Then
Me.OrderBy = .OrderBy
Me.OrderByOn = True
End If
End With

You'll probably want to confirm that the form is open first.
 
Graham,

Thanks for the lead. I have placed the code in the
OpenReport action, but can't get it to take effect. I
suspect this may be related to the Order By settings that
I have on the originating form and on the report. What
should these be?

When you say "Report_Open" event procedure, are you
referring to the DoCmd that is a part of the Command
Button or the procedure that is associated with the report
itself? I assumed it was the report itself, but wanted to
be sure.

Lloyd

-----Original Message-----
Hi Lloyd

In your Report_Open event procedure, set the OrderBy property of the report
to the same as that of the form:

With Forms![YourForm]
If .OrderByOn Then
Me.OrderBy = .OrderBy
Me.OrderByOn = True
End If
End With

You'll probably want to confirm that the form is open first.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

I have defined an on click action in button on a form as
follows:

DoCmd.OpenReport stDocName, acViewPreview, , Forms!
frmMyForm.Filter

This opens the report with the records selected by the
user through the Filter by Form feature. How do I go
about getting the sort order in the report to match the
dsiplay order set by the user using the sort buttons on
the toolbar in the form?

thanks,

Lloyd


.
 
One more followup - the language you suggest does seem to
bring the "orderby" value into the properties of the
report. But it does not get implemented when the report
is displayed - the ordering remains unchanged.

Lloyd

-----Original Message-----
Graham,

Thanks for the lead. I have placed the code in the
OpenReport action, but can't get it to take effect. I
suspect this may be related to the Order By settings that
I have on the originating form and on the report. What
should these be?

When you say "Report_Open" event procedure, are you
referring to the DoCmd that is a part of the Command
Button or the procedure that is associated with the report
itself? I assumed it was the report itself, but wanted to
be sure.

Lloyd

-----Original Message-----
Hi Lloyd

In your Report_Open event procedure, set the OrderBy property of the report
to the same as that of the form:

With Forms![YourForm]
If .OrderByOn Then
Me.OrderBy = .OrderBy
Me.OrderByOn = True
End If
End With

You'll probably want to confirm that the form is open first.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

message


.
.
 
Hi Lloyd

The code should be in the event procedure associated with the report's Open
event. This procedure is called Report_Open. The entire procedure should
look like this:

Private Sub Report_Open(Cancel As Integer)
With Forms![Name of your form]
If .OrderByOn Then
Me.OrderBy = .OrderBy
Me.OrderByOn = True
End If
End With
End Sub
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


Chappie2 said:
One more followup - the language you suggest does seem to
bring the "orderby" value into the properties of the
report. But it does not get implemented when the report
is displayed - the ordering remains unchanged.

Lloyd

-----Original Message-----
Graham,

Thanks for the lead. I have placed the code in the
OpenReport action, but can't get it to take effect. I
suspect this may be related to the Order By settings that
I have on the originating form and on the report. What
should these be?

When you say "Report_Open" event procedure, are you
referring to the DoCmd that is a part of the Command
Button or the procedure that is associated with the report
itself? I assumed it was the report itself, but wanted to
be sure.

Lloyd

-----Original Message-----
Hi Lloyd

In your Report_Open event procedure, set the OrderBy property of the report
to the same as that of the form:

With Forms![YourForm]
If .OrderByOn Then
Me.OrderBy = .OrderBy
Me.OrderByOn = True
End If
End With

You'll probably want to confirm that the form is open first.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

message
I have defined an on click action in button on a form as
follows:

DoCmd.OpenReport stDocName, acViewPreview, , Forms!
frmMyForm.Filter

This opens the report with the records selected by the
user through the Filter by Form feature. How do I go
about getting the sort order in the report to match the
dsiplay order set by the user using the sort buttons on
the toolbar in the form?

thanks,

Lloyd


.
.
 
Thanks, Graham.

But something about my setup just isn't allowing it to
work.

The form is based on a query. When a sort is applied, the
OrderBy field in the form properties is updated with the
query.field. I have added your suggested language to the
Open_Report event on the report, but when I click the
command button on the form, the report comes up but does
not reflect the ordering that was present in the form.
The properites of the report list the query.field in the
Order by field and OrderByOn is set to Yes.

Any other thoughts as to what is causing this problem?
Does the actual query need to be "open"? If so, where/how
would I do that?

I am using Access97 - could that be an issue?

Thanks, Lloyd
-----Original Message-----
Hi Lloyd

The code should be in the event procedure associated with the report's Open
event. This procedure is called Report_Open. The entire procedure should
look like this:

Private Sub Report_Open(Cancel As Integer)
With Forms![Name of your form]
If .OrderByOn Then
Me.OrderBy = .OrderBy
Me.OrderByOn = True
End If
End With
End Sub
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


One more followup - the language you suggest does seem to
bring the "orderby" value into the properties of the
report. But it does not get implemented when the report
is displayed - the ordering remains unchanged.

Lloyd

-----Original Message-----
Graham,

Thanks for the lead. I have placed the code in the
OpenReport action, but can't get it to take effect. I
suspect this may be related to the Order By settings that
I have on the originating form and on the report. What
should these be?

When you say "Report_Open" event procedure, are you
referring to the DoCmd that is a part of the Command
Button or the procedure that is associated with the report
itself? I assumed it was the report itself, but wanted to
be sure.

Lloyd


-----Original Message-----
Hi Lloyd

In your Report_Open event procedure, set the OrderBy
property of the report
to the same as that of the form:

With Forms![YourForm]
If .OrderByOn Then
Me.OrderBy = .OrderBy
Me.OrderByOn = True
End If
End With

You'll probably want to confirm that the form is open
first.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

message
I have defined an on click action in button on a
form
as
follows:

DoCmd.OpenReport stDocName, acViewPreview, , Forms!
frmMyForm.Filter

This opens the report with the records selected by the
user through the Filter by Form feature. How do I go
about getting the sort order in the report to match the
dsiplay order set by the user using the sort buttons on
the toolbar in the form?

thanks,

Lloyd


.

.


.
 
The form is based on a query. When a sort is applied, the
OrderBy field in the form properties is updated with the
query.field. I have added your suggested language to the
Open_Report event on the report, but when I click the
command button on the form, the report comes up but does
not reflect the ordering that was present in the form.
The properites of the report list the query.field in the
Order by field and OrderByOn is set to Yes.


Not sure if this will help you, but a report's Sorting and
Grouping take precedence over the OrderBy property (and the
record source query's sorting is ignored). To change the
sort field in the report's Open event, you can modify the
field in a group level:

Me.GroupLevel.ControlSource = "somefieldname"
 
Hi Lloyd

Marsh has probably hit the nail on the head. Do you have sorting/grouping
levels defined? If so, how do you want the modified sortorder to affect
them? Are they really necessary?
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Thanks, Graham.

But something about my setup just isn't allowing it to
work.

The form is based on a query. When a sort is applied, the
OrderBy field in the form properties is updated with the
query.field. I have added your suggested language to the
Open_Report event on the report, but when I click the
command button on the form, the report comes up but does
not reflect the ordering that was present in the form.
The properites of the report list the query.field in the
Order by field and OrderByOn is set to Yes.

Any other thoughts as to what is causing this problem?
Does the actual query need to be "open"? If so, where/how
would I do that?

I am using Access97 - could that be an issue?

Thanks, Lloyd
-----Original Message-----
Hi Lloyd

The code should be in the event procedure associated with the report's Open
event. This procedure is called Report_Open. The entire procedure should
look like this:

Private Sub Report_Open(Cancel As Integer)
With Forms![Name of your form]
If .OrderByOn Then
Me.OrderBy = .OrderBy
Me.OrderByOn = True
End If
End With
End Sub
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


One more followup - the language you suggest does seem to
bring the "orderby" value into the properties of the
report. But it does not get implemented when the report
is displayed - the ordering remains unchanged.

Lloyd


-----Original Message-----
Graham,

Thanks for the lead. I have placed the code in the
OpenReport action, but can't get it to take effect. I
suspect this may be related to the Order By settings that
I have on the originating form and on the report. What
should these be?

When you say "Report_Open" event procedure, are you
referring to the DoCmd that is a part of the Command
Button or the procedure that is associated with the
report
itself? I assumed it was the report itself, but wanted
to
be sure.

Lloyd


-----Original Message-----
Hi Lloyd

In your Report_Open event procedure, set the OrderBy
property of the report
to the same as that of the form:

With Forms![YourForm]
If .OrderByOn Then
Me.OrderBy = .OrderBy
Me.OrderByOn = True
End If
End With

You'll probably want to confirm that the form is open
first.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

in
message
I have defined an on click action in button on a form
as
follows:

DoCmd.OpenReport stDocName, acViewPreview, , Forms!
frmMyForm.Filter

This opens the report with the records selected by the
user through the Filter by Form feature. How do I go
about getting the sort order in the report to match the
dsiplay order set by the user using the sort buttons on
the toolbar in the form?

thanks,

Lloyd


.

.


.
 
Thanks Graham and Marshall,

I had forgotten that trying to resolve the problem in a
different way I had installed groupings in the report that
were controlling. Once I removed them, the report works
fine.

Thanks for your patience in getting me through this.

Lloyd
-----Original Message-----
Hi Lloyd

Marsh has probably hit the nail on the head. Do you have sorting/grouping
levels defined? If so, how do you want the modified sortorder to affect
them? Are they really necessary?
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Thanks, Graham.

But something about my setup just isn't allowing it to
work.

The form is based on a query. When a sort is applied, the
OrderBy field in the form properties is updated with the
query.field. I have added your suggested language to the
Open_Report event on the report, but when I click the
command button on the form, the report comes up but does
not reflect the ordering that was present in the form.
The properites of the report list the query.field in the
Order by field and OrderByOn is set to Yes.

Any other thoughts as to what is causing this problem?
Does the actual query need to be "open"? If so, where/how
would I do that?

I am using Access97 - could that be an issue?

Thanks, Lloyd
-----Original Message-----
Hi Lloyd

The code should be in the event procedure associated
with
the report's Open
event. This procedure is called Report_Open. The
entire
procedure should
look like this:

Private Sub Report_Open(Cancel As Integer)
With Forms![Name of your form]
If .OrderByOn Then
Me.OrderBy = .OrderBy
Me.OrderByOn = True
End If
End With
End Sub
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


"Chappie2" <[email protected]> wrote
in
message
One more followup - the language you suggest does
seem
to
bring the "orderby" value into the properties of the
report. But it does not get implemented when the report
is displayed - the ordering remains unchanged.

Lloyd


-----Original Message-----
Graham,

Thanks for the lead. I have placed the code in the
OpenReport action, but can't get it to take effect. I
suspect this may be related to the Order By settings that
I have on the originating form and on the report. What
should these be?

When you say "Report_Open" event procedure, are you
referring to the DoCmd that is a part of the Command
Button or the procedure that is associated with the
report
itself? I assumed it was the report itself, but wanted
to
be sure.

Lloyd


-----Original Message-----
Hi Lloyd

In your Report_Open event procedure, set the OrderBy
property of the report
to the same as that of the form:

With Forms![YourForm]
If .OrderByOn Then
Me.OrderBy = .OrderBy
Me.OrderByOn = True
End If
End With

You'll probably want to confirm that the form is open
first.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

in
message
I have defined an on click action in button on a form
as
follows:

DoCmd.OpenReport stDocName, acViewPreview, , Forms!
frmMyForm.Filter

This opens the report with the records selected
by
the
user through the Filter by Form feature. How do
I
go
about getting the sort order in the report to
match
the
dsiplay order set by the user using the sort buttons on
the toolbar in the form?

thanks,

Lloyd


.

.



.


.
 
Back
Top