From: Vincent on
This probably cannot be done, but I thought I would ask anyhow. I
have a subreport in which I wish to assign the controlsource of
several controls dynamically at runtime.

The first time the controlsource is assigned in report_open() of the
subreport, everything works fine. However, if I try to reassign the
controlsource a second time, I receive the following error:

"You can't set the Record Source property in print preview or after
printing has started."

But, I want to reassign the controlsource, as the controls in question
may need to be reassigned to a different field for each page of the
report.

I just want to know if this is possible. Thanks.

Vincent
From: Roger on
On Jul 30, 9:17 am, Vincent <animedrea...(a)verizon.net> wrote:
> This probably cannot be done, but I thought I would ask anyhow.  I
> have a subreport in which I wish to assign the controlsource of
> several controls dynamically at runtime.
>
> The first time the controlsource is assigned in report_open() of the
> subreport, everything works fine.  However, if I try to reassign the
> controlsource a second time, I receive the following error:
>
> "You can't set the Record Source property in print preview or after
> printing has started."
>
> But, I want to reassign the controlsource, as the controls in question
> may need to be reassigned to a different field for each page of the
> report.
>
> I just want to know if this is possible.  Thanks.
>
> Vincent

you could create multiple controls, each with their controlsource and
hide/display the controls you need/want on each page
From: Vincent on
On Jul 30, 11:21 am, Roger <lesperan...(a)natpro.com> wrote:
> On Jul 30, 9:17 am, Vincent <animedrea...(a)verizon.net> wrote:
>
>
>
> > This probably cannot be done, but I thought I would ask anyhow.  I
> > have a subreport in which I wish to assign the controlsource of
> > several controls dynamically at runtime.
>
> > The first time the controlsource is assigned in report_open() of the
> > subreport, everything works fine.  However, if I try to reassign the
> > controlsource a second time, I receive the following error:
>
> > "You can't set the Record Source property in print preview or after
> > printing has started."
>
> > But, I want to reassign the controlsource, as the controls in question
> > may need to be reassigned to a different field for each page of the
> > report.
>
> > I just want to know if this is possible.  Thanks.
>
> > Vincent
>
> you could create multiple controls, each with their controlsource and
> hide/display the controls you need/want on each page

Well, normally that would work. But, to complicate matters, I do not
know the name of the fields until runtime.

Vincent
From: Don Leverton on
Hi Vincent,

Might I suggest that you post the code that *does* work "the first time"?
It might help me (us) to understand what you are trying to accomplish.
Have you tried putting that code into the sub-report's (detail section)
OnFormat / OnPrint event?

i.e.
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
' Your code here
End Sub

or

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
' Your code here
End Sub
==============
I'm pretty sure that these two subreport events fire every time that the
detail section of the main report is "re-drawn", but if not, perhaps the
code could be called from the same main report's OnFormat / OnPrint events?

HTH,
Don

"Vincent" <animedreamer(a)verizon.net> wrote in message
news:8ec7f597-5ceb-463b-9f67-cd0dd1618bb3(a)l14g2000yql.googlegroups.com...
> On Jul 30, 11:21 am, Roger <lesperan...(a)natpro.com> wrote:
>> On Jul 30, 9:17 am, Vincent <animedrea...(a)verizon.net> wrote:
>>
>>
>>
>> > This probably cannot be done, but I thought I would ask anyhow. I
>> > have a subreport in which I wish to assign the controlsource of
>> > several controls dynamically at runtime.
>>
>> > The first time the controlsource is assigned in report_open() of the
>> > subreport, everything works fine. However, if I try to reassign the
>> > controlsource a second time, I receive the following error:
>>
>> > "You can't set the Record Source property in print preview or after
>> > printing has started."
>>
>> > But, I want to reassign the controlsource, as the controls in question
>> > may need to be reassigned to a different field for each page of the
>> > report.
>>
>> > I just want to know if this is possible. Thanks.
>>
>> > Vincent
>>
>> you could create multiple controls, each with their controlsource and
>> hide/display the controls you need/want on each page
>
> Well, normally that would work. But, to complicate matters, I do not
> know the name of the fields until runtime.
>
> Vincent