Oh, really? The how does this code from one of my production reports work,
then?
Private Sub Report_Open(Cancel As Integer)
On Error GoTo Report_Open_Error
'Activity is always last
Me.GroupLevel(5).ControlSource = "Activity"
With Forms!frmUPOreports
'Determine which Subtotals have been selected
'HomeRooom
If .chkHomeRoom Then
Me.GroupLevel(4).ControlSource = "PerformAcctUnit"
Else
Me.GroupLevel(4).ControlSource = Me.GroupLevel(5).ControlSource
End If
'Pool
If .chkPool Then
Me.GroupLevel(3).ControlSource = "Pool"
Else
Me.GroupLevel(3).ControlSource = Me.GroupLevel(4).ControlSource
End If
'BillNetwork
If .chkBillNetwork Then
Me.GroupLevel(2).ControlSource = "BillNetwork"
Else
Me.GroupLevel(2).ControlSource = Me.GroupLevel(3).ControlSource
End If
'MasterActivity
If .chkMActivity Then
Me.GroupLevel(1).ControlSource = "MActivity"
Else
Me.GroupLevel(1).ControlSource = Me.GroupLevel(2).ControlSource
End If
End With
'Top Level For Billable Product Offering
Me.GroupLevel(0).ControlSource = "ProjectId"
Regarding your >(Me.GroupLevel(5).ControlSource = "Activity").<
You're setting the Control Source to a particular Field, the
[Activity] field, not to a particular value in that field.
Let's make a test.
Add an unbound text control to the report (in the Header or Page
Header or Detail section, whatever).
Let's name the control "TestTextBox"
Code the Report's Open event to what the OP wanted to display
"Andrew".
Me![TestTextBox] = "Andrew" (as per your original reply to the OP.)
Run the report. It should generate Error 2448 "You can't assign a
value to this object"
Now change the Open event code to:
Me![TestTextBox].ControlSource = "Activity" or whatever field contains
the value "Andrew". In my test Db it would be [FirstName].
Run the report and you will get what ever the value of the [Activity]
field is, but not the word "Activity". The OP asked to have the
specific value "Andrew" displayed, (TestTextBox.Value = "Andrew") not
the value of a particular field.
Now if you move the code Me![TestTextBox] ="Andrew" from the Report's
Open event to the Report's Report Header Format event, it works just
fine. The report displays the word "Andrew".