dbTalk Databases Forums  

Reports -- Dynamic ControlSource

comp.databases.ms-access comp.databases.ms-access


Discuss Reports -- Dynamic ControlSource in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Vincent
 
Posts: n/a

Default Reports -- Dynamic ControlSource - 07-30-2010 , 10:17 AM






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

Reply With Quote
  #2  
Old   
Roger
 
Posts: n/a

Default Re: Reports -- Dynamic ControlSource - 07-30-2010 , 10:21 AM






On Jul 30, 9:17*am, Vincent <animedrea... (AT) verizon (DOT) net> wrote:
Quote:
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

Reply With Quote
  #3  
Old   
Vincent
 
Posts: n/a

Default Re: Reports -- Dynamic ControlSource - 07-30-2010 , 10:32 AM



On Jul 30, 11:21*am, Roger <lesperan... (AT) natpro (DOT) com> wrote:
Quote:
On Jul 30, 9:17*am, Vincent <animedrea... (AT) verizon (DOT) 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

Reply With Quote
  #4  
Old   
Don Leverton
 
Posts: n/a

Default Re: Reports -- Dynamic ControlSource - 07-30-2010 , 12:14 PM



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 (AT) verizon (DOT) net> wrote

Quote:
On Jul 30, 11:21 am, Roger <lesperan... (AT) natpro (DOT) com> wrote:
On Jul 30, 9:17 am, Vincent <animedrea... (AT) verizon (DOT) 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

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.