Setting the control source property in runtime

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
 
A

Allen Browne

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.
 
M

Marshall Barton

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top