How to sort records in Ascending or Descending order though VBA in Access 2002 RRS feed

  • Question

  • Have a form named “RouteDriversMain” and subform named “RouteDrivers”, also a report named “RouteDailyReportsDrivers”. The subform is where all the records are shown. The name of one of the fields is “Driver”.  The report has a “Driver” Header and Driver footer, both are used and of course that means that the sorting and grouping is set to the field “Driver”. I have a form named “RouteDriversMainParameterPopUp2” with a command button with the code below on the on click property    

    DoCmd.OpenReport "RouteDailyReportDrivers", acViewPreview    

    DoCmd.PrintOut A_PRINTALL, , , , 1, 0    

    DoCmd.Close A_REPORT, "RouteDailyReportDrivers"    

    DoCmd.Close acForm, "RouteDriversMainParameterPopUp2"

    I need to be able that if  in the subform the “Driver” field is ascending order, that the records printed in the report are also in ascending order, and if they are in descending order, that they print in descending order. Thank you for your help.

    Mario Jaile

    Friday, July 14, 2017 12:42 PM


  • Did you use the Report_Open event like I mentioned? Can you post your code?

    Paul ~~~~ Microsoft MVP (Visual Basic)

    • Marked as answer by dailymeat Monday, July 17, 2017 2:53 PM
    Monday, July 17, 2017 1:19 PM

All replies