Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Aug 2002
    Location
    Minneapolis, MN, Minnesota
    Posts
    162
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Changing Sort Order in VBA (2K2)

    I have a report (rptClientByLocation) in which I would like to change the way it sorts the records in the Detail Section based on input from a check box (SortByDate) on a dialog form (fdlgLocationSelector).
    If I check SortByDate then I want the report to sort the records by the field CertFrom.
    If I leave SortByDate unchecked then I want the report to sort the records by the field ClientName.

    In how would this be written in VBA? In what section of the report? What event would this be placed?
    Easy Access

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Changing Sort Order in VBA (2K2)

    You can set the sort order in the On Open event of the report::

    Private Sub Report_Open()
    If Forms!fdlgLocationSelector!SortByDate = True Then
    Me.OrderBy = "CertForm"
    Else
    Me.OrderBy = "ClientName"
    End If
    Me.OrderByOn = True
    End If

    Note: don't specify a sort order in the Sorting and Grouping window, this might conflict with the code. Grouping levels are OK.

  3. #3
    2 Star Lounger
    Join Date
    Aug 2002
    Location
    Minneapolis, MN, Minnesota
    Posts
    162
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Changing Sort Order in VBA (2K2)

    I bow to your vast & incredible knowledge...Thank you! <img src=/S/bow.gif border=0 alt=bow width=15 height=15>
    Easy Access

Posting Permissions

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