Results 1 to 7 of 7
  1. #1
    shkspeare is offline Novice
    Windows 10 Office 365
    Join Date
    Sep 2020
    Posts
    6

    change sort when refresh report on form

    I have a Search form with a Report on it, gets run based on selecting criteria. Before run, it creates dynamic pass-thru SQL based on criteria chosen, then requeries the report.

    Need to add a SORT by Option- to change the default SORT (groups and sorts 6 or so fields).



    It works when form is opened, with code in REPORT OPEN event to change the default sort to:

    Code:
    Me.GroupLevel(0).ControlSource = "symbolid"
            Me.GroupLevel(1).ControlSource = "TicketID"
            Me.GroupLevel(2).ControlSource = "initLeg"
    I tried putting this code in onCurrent event on Report, but didnt work. Requerying report doesnt do, as report already open, so code doesnt fire again.

    IS there a way to change an embedded Report's sort group order, after click Search button, using new criteria?

    (I thought of closing report and re-opening to get the ONOpen code above to fire...but not sure how to implement closing a subform/report on a Form, or if even possible..

    thanks!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    I have a report with a subreport, both in Report view. The report has filtering/sorting options, each of which call a report-level function. The sorting works fine from there.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    shkspeare is offline Novice
    Windows 10 Office 365
    Join Date
    Sep 2020
    Posts
    6
    Yes, I've done with subreport within report, so each time opening, vba can change Sort.

    But here, the report resides within the Search Form, so the Report stays open - but want it to change the Sort if Search criteria changes, but that happens in the OnOpen event...so I cant figure how to refresh it and change sort -

  4. #4
    shkspeare is offline Novice
    Windows 10 Office 365
    Join Date
    Sep 2020
    Posts
    6
    so clicking on control on parent report, alters the subreport? I'm curious how you change the SORT on subreport (assuming the main report remains open?

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    I'm not sure it matters that your report is within a form, I'm talking about my report/subreport staying open too. User clicks on options in the report, subreport responds appropriately. My code looks like:

    Code:
        Select Case Me.FraSort
            Case 2
                Me.BreakDownSheet.Report.GroupLevel(0).ControlSource = "SomeField"
                Me.BreakDownSheet.Report.GroupLevel(1).ControlSource = "Car_No"
            Case Else
                Me.BreakDownSheet.Report.GroupLevel(0).ControlSource = "DifferentField"
                Me.BreakDownSheet.Report.GroupLevel(1).ControlSource = "Car_No"
        End Select
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    shkspeare is offline Novice
    Windows 10 Office 365
    Join Date
    Sep 2020
    Posts
    6
    thanks Paul! i kept thinking the vba had to be in the subreport object...i put in main form and works -

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 06-25-2015, 01:27 PM
  2. Refresh / Requry Subform Upon Combobox Change
    By michael.legge@rbc.com in forum Access
    Replies: 3
    Last Post: 06-18-2013, 06:28 AM
  3. Replies: 2
    Last Post: 02-25-2013, 10:08 PM
  4. Refresh form when values change
    By stevewoo in forum Programming
    Replies: 4
    Last Post: 11-30-2011, 06:54 AM
  5. Replies: 1
    Last Post: 03-14-2011, 11:11 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums