Results 1 to 4 of 4
  1. #1
    SSgtJ is offline Novice
    Windows XP Access 2010 (version 14.0)
    Join Date
    Jan 2010
    Posts
    4

    How to Automatically Group

    I have a report that is based on a form and the form filters the report automatically very nicely. The next step that I would like to take is can I change the grouping on my report from my form?


    Lets say form frmFilter has 6 controls on it 3 for filtering and 3 for grouping. grp1 grp2 and grp3. the filtering part I have down, now I jsut need to figure out how to automatically group the report by grp1 grp2 or grp3. Any help would be great.

    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,521
    I'm not sure I'm clear on exactly what you're trying to do, but you can change the grouping in the report's open event:

    Me.GroupLevel(0).ControlSource = "CarType"

    You could use a form control instead of hard-coding, as long as the control contained the field name (that's part of a routine that tests an option group on a form).
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    SSgtJ is offline Novice
    Windows XP Access 2010 (version 14.0)
    Join Date
    Jan 2010
    Posts
    4
    I have a report that is filtered by a form. This Report is normally grouped by MFG, Then by Type. I would like to control the grouping function from the form as in to say If I filter by MFG then I only want to group by Type instead of the default MFG then Type. Ultimately I would like to have a control on the form that allows me to filter and group by any combination I attached a sample very basic but you can see the 2 reports. rptDenomMix is by Number then by type which is great but now I want to be able to click something in the form to lets say take out the type grouping leaving the Number group giving me whats in the copy rptDenomMix.

    So in a nutshell I would like the ability to add and remove groupings but using the form as like a dashboard for this process.
    hope this helps!

    Thanks

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I don't have time to look at the sample right now, but here's the full code from above, which changes or eliminates the grouping based on user selections (an option group on a form). Post back if you're still stuck:

    Code:
    Private Sub Report_Open(Cancel As Integer)
      Select Case Forms!frmReports.fraGrouping
        Case 1 'sort/group on car type
          Me.GroupLevel(0).ControlSource = "CarType"
          Me.txtGroup.ControlSource = "CarDesc"
        Case 2 'sort/group on company
          Me.GroupLevel(0).ControlSource = "Company"
          Me.txtGroup.ControlSource = "Company"
        Case 3 'sort on date/time, no grouping
          Me.GroupLevel(0).ControlSource = "DispDateTime"
          Me.txtGroup.ControlSource = "DispDateTime"
          Me.GroupHeader0.Visible = False
      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. Automatically choose which report?
    By Lockrin in forum Reports
    Replies: 2
    Last Post: 12-28-2009, 02:41 PM
  2. I want to automatically pass a value to a query
    By Slategrey252 in forum Queries
    Replies: 1
    Last Post: 10-01-2009, 05:38 AM
  3. Automatically get Excel data
    By TimG in forum Import/Export Data
    Replies: 2
    Last Post: 08-24-2009, 06:38 AM
  4. columns for group detail but not group header?
    By Coolpapabell in forum Reports
    Replies: 0
    Last Post: 08-21-2009, 08:53 AM
  5. Automatically Writing SQL From A Table
    By smitstev in forum Programming
    Replies: 1
    Last Post: 06-05-2009, 09:38 AM

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