Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting a report based on subform

Status
Not open for further replies.

issunboshi

IS-IT--Management
Apr 27, 2004
24
US
Everyone, need some help here. I am inexperienced at writing access programs, but I have been able to stumble my way through a program for my company. I have a subform, that uses a query as it's source that is displayed in a dataview.
The same query is used as the source for a report that displays the same information that is displayed in the subform dataview.

What I am wanting to know is if there is a way for the report to display the same data and sort sequence that is on the dataview. If I display the information in the data view, I right click on a column and change the sort sequence, i want the report that prints out to reflect that same data sort. Then close the report, change the sort and have the new report that prints to have the lastest data sort.

The report is printed using a docmd.OpenReport command. Is this even possible? Or am I up the proverbial creek?

ken
 
It may be possible. Let us say your form is called frmForm and that it is open when you open the report. Add this code to the report:

Code:
Private Sub Report_Open(Cancel As Integer)
Me.OrderBy = Forms!frmForm.OrderBy
Me.OrderByOn = Forms!frmForm.OrderByOn
End Sub
 
Thanks for the response Remou. Unfortunately this produed a runtime error. I get Run-time error '438': Object doesn't support this property or method. Any other ideas?

Ken
 
I tested the above, so can we narrow it down to the line that is causing the problem? Also, please post the code as modified for your application.
 
Remou, thanks for your efforts, but I just went ahead and created a separate form for producing the report in the desired sort sequence. Once again, thanks for your efforts.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top