dynamic report header
Results 1 to 4 of 4

Thread: dynamic report header
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Feb 2003
    Posts
    392
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default dynamic report header

    Access 365

    I have a QBF with a combobox "CboGrouping" that tells the report the tow grouping the user wants. (code from Allen Brown)
    Now I need to add the correct fields in the Header area...
    i.e. if case 1, then District Header would be [District] and District Header would be [District]
    if case 2 District Header would be [District] and District Header would be [District]



    Private Sub Report_Open(Cancel As Integer)


    Select Case Forms!f_QBF!cboGrouping
    Case "1" 'Site & District
    Me.GroupLevel(0).ControlSource = "Site"
    Me.GroupLevel(1).ControlSource = "District"


    Case "2" 'District & Site
    Me.GroupLevel(0).ControlSource = "District"
    Me.GroupLevel(1).ControlSource = "Site"

    End Select
    End Sub

  2. #2
    Board Regular
    Join Date
    Jul 2010
    Posts
    432
    Post Thanks / Like
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Default Re: dynamic report header

    Add 2 unbound controls to your report and set the the same way you are setting your GroupLevel:


    You will need to change the name of the controls to match what you name your unbound controls.

    Code:
    Private Sub Report_Open(Cancel As Integer)
    
    
    
    
    Select Case Forms!f_QBF!cboGrouping
    Case "1" 'Site & District
    Me.GroupLevel(0).ControlSource = "Site"
    Me.GroupLevel(1).ControlSource = "District"
    Me.Text1.ControlSource = "Site"
    Me.Text2.ControlSource = "District"
    
    
    Case "2" 'District & Site
    Me.GroupLevel(0).ControlSource = "District"
    Me.GroupLevel(1).ControlSource = "Site"
    Me.Text1.ControlSource = "District"
    Me.Text2.ControlSource = "Site"
    
    
    End Select
    End Sub

  3. #3
    Board Regular
    Join Date
    May 2013
    Posts
    625
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: dynamic report header

    Could you have ?
    Code:
    Private Sub Report_Open(Cancel As Integer)
    
    Select Case Forms!f_QBF!cboGrouping
    Case "1" 'Site & District
        Me.GroupLevel(0).ControlSource = "Site"
        Me.GroupLevel(1).ControlSource = "District"
    
    
    Case "2" 'District & Site
        Me.GroupLevel(0).ControlSource = "District"
        Me.GroupLevel(1).ControlSource = "Site"
    
    End Select
    Me.Text1.ControlSource = Me.GroupLevel(0).ControlSource
    Me.Text2.ControlSource = Me.GroupLevel(1).ControlSource
    End Sub
    Well done for interpreting that from the original post as well.
    Office 2007
    Access novice. Sometimes trying to give something back

  4. #4
    Board Regular
    Join Date
    Feb 2003
    Posts
    392
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: dynamic report header

    Thank you this works great

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •