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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting report using Property Sheet 1

Status
Not open for further replies.

hefly

Technical User
Feb 6, 2008
134
US
How does one sort a report using the property sheet?

I have tried using just the "FieldName" in quotes on the Order By field on the property sheet.

Nothing sorts.

Please advise.

Thanks.

Hefly
 
Thank you for replying Duane. I discovered that the sorting and grouping had been selected.

Aside from the sorting and grouping. I couldn't find any examples anywhere of using the property sheet to set filters.


I have a field named LastName. How would I set the filter in the property sheet to filter on Lastname=tyler ?

Pressing the F1 key on the property sheet brings up the Form.Filter Property.

I set Me.Filter="Lastname = 'tyler' " and I get a parameter box. If I put in the name tyler, which is in my database, I get a message box "There is no data for this report. Cancelling report.

I would like to understand how to use the property sheet to set filters and order by, but I don't know where to begin.

Thanks.

Hefly


 
I would never set these properties in the property sheet. If you want to filter a report based on the last name, you should create a form with a combo box (cboLastName) that displays all last names for the user to select. You then use the command button wizard to create a button that opens your report.

Modify the code created by the wizard to something like:
Code:
   Dim stDocName as String
   Dim strWhere as String
   strWhere = "1=1 "
   stDocName = "rptYourReport"
   If Not IsNull(Me.cboLastName) Then
      strWhere = strWhere & " AND [LastName] =""" & _
         Me.cboLastName & """ "
   End If
   DoCmd.OpenReport stDocName, acPreview, , strWhere
The strWhere will set the filter property for you.

If you want to be able to dynamically change the sorting of the report during runtime, use the code from Allen Browne's web site
Duane
Hook'D on Access
MS Access MVP
 
Thanks Duane. I don't understand what's wrong with using the property sheets, but your solution is exactly what I'm looing for. That will work out swell.

Again, many thanks.

Hefly
 
Using a property sheet suggests you have to open the report in design view to set values. Also, sorting set in the Sort By property is over-ridden by the sorting and grouping dialog.

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top