dynamic report header

deb

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

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
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
 
Upvote 0
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:
 
Upvote 0

Forum statistics

Threads
1,213,514
Messages
6,114,078
Members
448,547
Latest member
arndtea

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top