dynamic report header

deb

Active Member
Joined
Feb 1, 2003
Messages
396
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
 

Some videos you may like

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

stumac

Active Member
Joined
Jul 16, 2010
Messages
471
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.[COLOR=#ff0000]Text1[/COLOR].ControlSource = "Site"
Me.[COLOR=#ff0000]Text2[/COLOR].ControlSource = "District"


Case "2" 'District & Site
Me.GroupLevel(0).ControlSource = "District"
Me.GroupLevel(1).ControlSource = "Site"
Me.[COLOR=#ff0000]Text1[/COLOR].ControlSource = "District"
Me.[COLOR=#ff0000]Text2[/COLOR].ControlSource = "Site"


End Select
End Sub
 

welshgasman

Well-known Member
Joined
May 25, 2013
Messages
820
Could you have ?
Rich (BB 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. :confused:
 

Watch MrExcel Video

Forum statistics

Threads
1,102,203
Messages
5,485,332
Members
407,497
Latest member
astaha

This Week's Hot Topics

  • Finding issue in If elseif else with For each Loop
    Finding issue in If elseif else with For each Loop I have tried this below code but i'm getting in Y column filled with W005. Colud you please...
  • MsgBox Error
    Hi Guys, I have the below error show up when i try and run my macro in File1 but works fine if i copy and paste the same code into file2. [ATTACH...
  • CELL FORMAT - IF CONDITION
    My Cell Format is [B]""0.00" Cr". [/B]But in the cell, it is showing 123.00 for editing. (123 is entry figure). (Data imported from other...
  • Show numbers nearly the same
    Is this possible. I have a number that can change very time eg 0.00001234 Then I have a lot of numbers 0.0000001, 0.0000002, 0.00000004...
  • Please i need your help to create formula
    I need a formula in cell B8 to do this >>if b1=1 then multiply ( cell b8) by 10% ,if b1=2 multiply by 20%,if=3 multiply by 30%. Thank you in...
  • Got error while adding column and filter
    Got error while adding column and filter In column Z has some like "Success" and "Error". I want to add column in AA if the Z cell value is...
Top