Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2002
    Posts
    192

    Unanswered: Sorting using OpenReport

    Is there a way to pass a sort to either the "filter" or "Criteria" properties in the docmd.OpenReport method?

    If so how would it go. I've tried something along the lines of. The first I thought would work but doesn't. The 2nd was a shot in the dark.

    DoCmd.OpenReport "rptMyReport", acViewPreview, "Order By TransactionID"

    DoCmd.OpenReport "rptMyReport", acViewPreview, , "Order By TransactionID"

    I have other means available to me but would like to explore the OpenReport avenue if possible first.

  2. #2
    Join Date
    Oct 2002
    Location
    NSW Australia
    Posts
    61
    Is there a reason that you can't use the Soting and Grouping options in the report design ?

    An alternate way is to set a custom recordsource OnOpen of the report using SQL.

    supply some more info and we may be able to help.

  3. #3
    Join Date
    Jun 2002
    Posts
    33
    Try something like this:

    "DoCmd.OpenReport "rptEmployers", acViewPreview, strSQL"

    where strSQL can be: strSQL="select * from Table where......"
    PacuIonut

  4. #4
    Join Date
    Oct 2002
    Posts
    48

    Pass OrderBy Parameter to Report thru Event

    You may bulid parameter Order by in form/button where you are calling Report. Then use that variable in Open Report event of report.


    Private Sub Report_Open(Cancel As Integer)
    Me.OrderBy = "field1, field2 "
    OR
    Me.OrderBy = [Forms]![Parameter Form]!OrderByString

    Me.OrderByOn
    End Sub

  5. #5
    Join Date
    Mar 2002
    Posts
    192

    Re: Pass OrderBy Parameter to Report thru Event

    Can't hard code it to the report because the user determines what fields to sort by. That last method looks promising. I'm going to give that one a try. tnx VSS.

  6. #6
    Join Date
    Mar 2002
    Posts
    192

    Re: Pass OrderBy Parameter to Report thru Event

    Cool it worked. Just saved me from having to rewrite the query in code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •