Sub GroupTest()
'Call to add grouping
'retval = AddGroupToReport("Products", "Product_Type", True, True)
'call to add sort
'retval = SetReportOrder("Products", "Product_Type")
End Sub
Function AddGroupToReport(rpt$, fld$, GrpHdr As Boolean, GrpFooter As Boolean)
On Error GoTo ErrTrap
Dim intGroupLevel
DoCmd.OpenReport rpt$, acViewDesign 'Open in Design View
intGroupLevel = CreateGroupLevel(rpt$, fld$, True, True) 'Mod the Group
DoCmd.Close acReport, rpt$, acSaveYes 'Close from Design View
Exit Function
ErrTrap:
Debug.Print Err.Number, Err.Description
Err = 0
End Function
Function SetReportOrder(rpt$, flds$)
DoCmd.OpenReport rpt$, acViewDesign 'Open in Design View
Reports(rpt$).OrderBy = flds$ 'Mod the Sort Property
DoCmd.Close acReport, rpt$, acSaveYes 'Close from Design View
End Function