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
.
.
.