setting the value of a report

D

Dan

Is it possible to set the value of a report. I know you can do this with a
form with something like:

Form![Form Name]![field] = ....

Can I do this with a report?
 
N

Nikos Yannacopoulos

Dan,

Indeed you can set a control's value on a form from outside the form, in
the way you say (note: tables have fields, forms have controls which may
- or may not - be bound to table fields), as long as the form is open.

In a report, though, it does not work in the same way; once a report is
opened, there is no way you can make changes from outside the report.
You can, though, do certain things from within the report, by executing
code on specific events such as, report open, section format or print
etc. Check out the events tab of properties for the form abd sections
objects. For instance, if you want to set the value of a control in the
detail section, you can use the detail section's Format event to do it,
like:
Me.ControlX = ...

HTH,
Nikos
 
D

Dan

What I am trying to do is I have a report that calculates the bills (balance,
an outstaning balance, looks up when the next payment is do and so forth) and
I have it so that when it is calculating the values it also saves all that
information in a table so if the person who receives the bill has any
questions on it or if we need to reprint the bill we can. So I have this bill
form that does all of the calculations and I want it so that I can reprint
previously sent out bills. If I have the user open the bill report it will
calculate the next bill. So do I have to make up another report that looks
the same and is just linked to the values on the form?

Nikos Yannacopoulos said:
Dan,

Indeed you can set a control's value on a form from outside the form, in
the way you say (note: tables have fields, forms have controls which may
- or may not - be bound to table fields), as long as the form is open.

In a report, though, it does not work in the same way; once a report is
opened, there is no way you can make changes from outside the report.
You can, though, do certain things from within the report, by executing
code on specific events such as, report open, section format or print
etc. Check out the events tab of properties for the form abd sections
objects. For instance, if you want to set the value of a control in the
detail section, you can use the detail section's Format event to do it,
like:
Me.ControlX = ...

HTH,
Nikos
Is it possible to set the value of a report. I know you can do this with a
form with something like:

Form![Form Name]![field] = ....

Can I do this with a report?
 
N

Nikos Yannacopoulos

Dan,

This is not easy to follow! From what I make out of it, you seemd to be
doing, or trying to do, some things you shouldn't.

To begin with, as a general rule, calculated values should not be
stored; if you can calculate them once, you can calculate them anytime,
and this is what you should be doing. Of course, like with any rule,
there can be (rare) exceptions.

If you still need to store some invoice calculations, do so in your
form; to make sure you only do that when raising a new invoice, and not
repeat the process when reviewing existing ones, you can either (a) use
a command button on the form to carry out the calculations and store the
results, so the user must manually choose to do so, or, (b) if you want
this to be an automated process, you can make your code execute only if
Me.NewRecord = True.

For the printing, you can use either a report, or the form itself, if
the layout is suitable (make any buttons visible on screen only). Though
not impossible, there is no reason why you would need to store data from
the report.

HTH,
Nikos
 
Top