Where do I initialize variables in a report?

  • Thread starter Thread starter Dennis
  • Start date Start date
D

Dennis

Hi,

Where do I initialize public variables in a report?

I have a public variable where I put a sequential item number on each print
line. In the On Open event, I initilalized this ublic variables to 0. I then
do a print preview and a print. The print preview works fine, but the print
picks up the count from where the print preview left off.


I moved my initialization the the Report Header On Print event and it works
fine.

Is this the right way to initialize this variable or is there a more
appropriate event to initialize my variable. I tried On Activate, but that
did not work.

If I did not provide enough information, please tell me what I am missing.

Thanks,

Dennis
 
Dennis said:
Where do I initialize public variables in a report?

I have a public variable where I put a sequential item number on each print
line. In the On Open event, I initilalized this ublic variables to 0. I then
do a print preview and a print. The print preview works fine, but the print
picks up the count from where the print preview left off.


I moved my initialization the the Report Header On Print event and it works
fine.

Is this the right way to initialize this variable or is there a more
appropriate event to initialize my variable. I tried On Activate, but that
did not work.


That whole idea won't work regardless of where/how you
initialize the variable.

Report event can be triggered nultiple times in any order so
calculations that try to work across more than a single
record can produce all kins of seeming strange results.

Instead, you should use aggregate functions to calculate
totals in header/footer sections. To get a sequential
number on each detail "line", use a text box with the
expression =1 and RunninSum set to either Over Group or Over
All
 
I would think the report header would work best. My question is why are you
even doing this. Typically you shouldn't need to use any code to aggregate or
calculate values.
 
Marsh,

Your comment: Report event can be triggered multiple times in any order so
calculations that try to work across more than a single record can produce
all kinds of seeming strange results.

Response: So I am learning. Thanks for the info.



Your comment: Instead, you should use aggregate functions to calculate
totals in header/footer sections. To get a sequential number on each detail
"line", use a text box with the expression =1 and RunningSum set to either
Over Group or Over All

Response: Ah, I did not know this. I believe that this answers my question.
Thank you very much.


Dennis
 
Duane

Your Comment: I would think the report header would work best.
Response: Thanks.

Your comment: My question is why are you even doing this. Typically you
shouldn't need to use any code to aggregate or calculate values.

Response: I want to put a sequential line number on each line. This report
is reviewed by three people in a meeting. It is a lot easier to have
everyone refer to line number 35 than to say everyone turn to page 3 and
count down 5 lines to get to Mr. Smith. It makes it easier to people to find
a line on the report.


Dennis
 
If you want to consecutively number records in your report, just do as Marsh
suggested. There is no need for any code.
 
Daune, Marsh,

How would I get a total count at the bottom of the report?

Do I just setup a "dummy" field in the query with a value of 1 and then
total that field?

What is the syntax for that?

I'm still climbing the learning cliff.

Thanks,

Dennis
 
Dennis said:
Daune, Marsh,

How would I get a total count at the bottom of the report?

Do I just setup a "dummy" field in the query with a value of 1 and then
total that field?

What is the syntax for that?

No need make it complicated. The easiest thing is to add a
text box to a group and/or the report header/footer and use
the expression =Count(*)

I see no reason in this case, but you could also use a text
box in the appropriate (depending on the Over Group or Over
All) footer section with an expression:
=[your running sum text box]
 
Back
Top