Results 1 to 3 of 3
  1. #1
    rsarracini is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2014
    Posts
    3

    Change Report GroupLevel(n) index in VBA

    Hi,



    I have 3 group levels in a report (GroupLevel(0), GroupLevel(1), GroupLevel(3)). I would like to be able to change the order of these based on user input (to change the report output). How do you in VBA change the index number (n) of a report group level (eg change GroupLevel(1) to GroupLevel(3)).

    I already open the report in design via code, so making the change in design mode is not a problem.
    Thanks

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    You wouldnt want to control a report in vba...too messy/compex.

    Just make 3 versions of the report w 3 sort orders.
    Let user pick the sort version they want.

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    I'd prefer not to maintain multiple copies of the same report, so I do it in code. Don't think of it as changing the index number, think of it as changing the field in each index number. Here's an example, though only with one level:

    Code:
    Private Sub Report_Open(Cancel As Integer)
      If Forms!frmShiftData.chkSummary = True Then
        Me.Detail.Visible = False
      End If
    
      Select Case Forms!frmShiftData.fraGroupBy
        Case 1    'group on dates
          Me.GroupLevel(0).ControlSource = "Enter_Date"
          Me.txtGroupHeader.ControlSource = "Enter_Date"
          Me.txtDetail.ControlSource = "Shift"
          Me.lblGroupLabel.Caption = "DOR Date"
          Me.lblDetailLabel.Caption = "Shift"
        Case 2    'group on shifts
          Me.GroupLevel(0).ControlSource = "Shift"
          Me.txtGroupHeader.ControlSource = "Shift"
          Me.txtDetail.ControlSource = "Enter_Date"
          Me.lblGroupLabel.Caption = "Shift"
          Me.lblDetailLabel.Caption = "DOR Date"
      End Select
      
    End Sub
    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: 05-13-2013, 07:06 PM
  2. Replies: 15
    Last Post: 09-06-2012, 06:25 PM
  3. Replies: 1
    Last Post: 03-07-2012, 09:00 AM
  4. Change of report layout
    By funsofinnih in forum Reports
    Replies: 1
    Last Post: 01-24-2012, 07:18 PM
  5. Can't change report name
    By kman42 in forum Reports
    Replies: 1
    Last Post: 10-19-2011, 02:40 PM

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