Setting the control source property in runtime

  • Thread starter Thread starter Herve Francois
  • Start date Start date
H

Herve Francois

I am trying to change the ControlSource property of a
groupLevel, when the Report_Open event is trigger. I have
followed an example from the Access help file but I keep
getting an error saying that I cannot change this property
when printing ha started....Am I missing something???

Thanks
 
You can set the ControlSource of the GroupLevel in Report_Open, so somehow
your code is running too late.

Set the report's On Open property to:
[Event Procedure]
Click the build button beside this. Make sure that's where the code is.
 
Herve said:
I am trying to change the ControlSource property of a
groupLevel, when the Report_Open event is trigger. I have
followed an example from the Access help file but I keep
getting an error saying that I cannot change this property
when printing ha started....Am I missing something???

Are you doing this for a subreport? A subreport's Open
event fires for each instance of the subreport, but you can
only change this sort of thing the first time. Not sure in
this case, but if that is your situation, try using a module
level flag variable to prevent the code from running more
than once:

Dim Initialized As Boolean
Sub Report_Open( . . .
If Not Initialized Then
Me.GroupLevel(x).ControlSource = "fieldname"
Initialized = True
End if
 
Back
Top