Parameter-based sorting

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tim Olson

    #1

    Parameter-based sorting

    I'm using a form to pass parameters to a query, with results displayed
    in a report. Currently, I'm using parameters as filter criteria in
    the query, and everything is running smoothly (or so it appears).
    However, I'd like to pass sorting parameters (i.e., field names from
    one of the tables being queried) via the form, allowing the user to
    populate the ORDER BY command. Is it possible to pass sorting
    parameters in Access 2000? I can't even replicate the desired
    behavior when working directly on the query.

    Thanks for the help.

    Tim

  • tina

    #2
    Re: Parameter-based sorting

    don't try to sort the records at the query level, do it at the report level.
    you should be able to set the OrderBy property in the report's Open event,
    as

    Me.OrderBy = "some field"
    Me.OrderByOn = True

    you can use a reference to a form control (the form must be open) instead of
    a hard-coded string value, or build the string dynamically, then assign it
    to the OrderBy property.

    hth


    "Tim Olson" <timo@cvenginee ring.comwrote in message
    news:1182361336 .152359.69750@n 2g2000hse.googl egroups.com...
    I'm using a form to pass parameters to a query, with results displayed
    in a report. Currently, I'm using parameters as filter criteria in
    the query, and everything is running smoothly (or so it appears).
    However, I'd like to pass sorting parameters (i.e., field names from
    one of the tables being queried) via the form, allowing the user to
    populate the ORDER BY command. Is it possible to pass sorting
    parameters in Access 2000? I can't even replicate the desired
    behavior when working directly on the query.
    >
    Thanks for the help.
    >
    Tim
    >

    Comment

    • Tim Olson

      #3
      Re: Parameter-based sorting

      Tina

      Thanks. Conceptually, I like doing the sort at the report level
      rather than the query level. I was about to ask for some help with
      the syntax for passing the parameters to the report for sorting, but I
      think I've got it:

      Me.OrderBy = "[" & [Forms]![frmParameters]![txtOrder1] & "], [" &
      [Forms]![frmParameters]![txtOrder2] & "], [" & [Forms]![frmParameters]!
      [txtOrder3] & "]"

      Thanks again.

      Tim

      On Jun 20, 2:08 pm, "tina" <nos...@address .comwrote:
      don't try to sort the records at the query level, do it at the report level.
      you should be able to set the OrderBy property in the report's Open event,
      as
      >
      Me.OrderBy = "some field"
      Me.OrderByOn = True
      >
      you can use a reference to a form control (the form must be open) instead of
      a hard-coded string value, or build the string dynamically, then assign it
      to the OrderBy property.
      >
      hth
      >
      "Tim Olson" <t...@cvenginee ring.comwrote in message
      >
      news:1182361336 .152359.69750@n 2g2000hse.googl egroups.com...
      >

      Comment

      • tina

        #4
        Re: Parameter-based sorting

        you're welcome :)


        "Tim Olson" <timo@cvenginee ring.comwrote in message
        news:1182430336 .723336.297560@ q75g2000hsh.goo glegroups.com.. .
        Tina
        >
        Thanks. Conceptually, I like doing the sort at the report level
        rather than the query level. I was about to ask for some help with
        the syntax for passing the parameters to the report for sorting, but I
        think I've got it:
        >
        Me.OrderBy = "[" & [Forms]![frmParameters]![txtOrder1] & "], [" &
        [Forms]![frmParameters]![txtOrder2] & "], [" & [Forms]![frmParameters]!
        [txtOrder3] & "]"
        >
        Thanks again.
        >
        Tim
        >
        On Jun 20, 2:08 pm, "tina" <nos...@address .comwrote:
        don't try to sort the records at the query level, do it at the report
        level.
        you should be able to set the OrderBy property in the report's Open
        event,
        as

        Me.OrderBy = "some field"
        Me.OrderByOn = True

        you can use a reference to a form control (the form must be open)
        instead of
        a hard-coded string value, or build the string dynamically, then assign
        it
        to the OrderBy property.

        hth

        "Tim Olson" <t...@cvenginee ring.comwrote in message

        news:1182361336 .152359.69750@n 2g2000hse.googl egroups.com...
        >

        Comment

        Working...