Reports from memory variables

  • Thread starter Thread starter Roger
  • Start date Start date
R

Roger

I've seen the argument that one should print from a Report and
not from a Form. OK, I give up. I'll do all my printing from
Reports.

That said, is it possible to populate a Report with public
variables calculated in a Form rather than from the fields of a
table on a disk? I have many occasions to do this. In my
limited knowledge of VB in Access 2000, I'm currently having to
create special tables populated from within a Form and then fed
to a Report. This means undesired reads and writes to a disk
rather than dealing strictly with memory variables which would
be much more efficient.

If it can be done, how do I do it?

Thanks,
Roger
 
You would normally create a query to act as the RecordSource for the report.

You can type calculations into the Field row in a report. For example, if
the due date is 30 days after the invoice date:
DueDate: DateAdd("d", 30, [InvoiceDate])

Another example from the Invoices query that feeds the Invoices report in
the Northwind sample database:
ExtendedPrice: CCur([Order
Details].UnitPrice*[Quantity]*(1-[Discount])/100)*100
 
Allen,

Thanks for getting back to me. I understand what you have said,
however my application is a bit different (I'll bet they all say
that). The company that I work for is into "metrics" which is a
measurement of the efficiency of a process. I have a database
of customer requested operations that were performed by my
organization over a period of time. In order to develop the
"metrics" for this particular process, I have to pick a given
month and then calculate/print things like average turn-around
time, average labor hours, average cost, quantity of requests
received, quantity of requests canceled, quantity of requests
completed, quantity of requests still active by the end of the
month (backlog).

Calculating these quantities is fairly straight forward and it's
done in the Form after the user enters the from/to dates for the
calculation. The next step is to print the information on a
formatted Report. What I have been doing in cases like this is
to create a 1-record table with fields that match the quantities
to be printed. From the Form, I stuff the table and then call
on the Report to do the printing. The Report reads the data
from the single record in the table, populates the Report, and
then prints the Report.

It seems to me that it would be a lot more efficient to simply
send the memory variables directly over to the Report rather
than out to the disk first in the single record table and then
back to the Report. This means that I would have to link
objects in the Report to memory variables rather than to fields
in a table. Can this be done?

Thanks,
Roger


You would normally create a query to act as the RecordSource for
the report.

You can type calculations into the Field row in a report. For
example, if
the due date is 30 days after the invoice date:
DueDate: DateAdd("d", 30, [InvoiceDate])

Another example from the Invoices query that feeds the Invoices
report in
the Northwind sample database:
ExtendedPrice: CCur([Order
Details].UnitPrice*[Quantity]*(1-[Discount])/100)*100
 
So you already have the results you want in text boxes on your form, and you
want to print a report that refers to those values?

Assuming the form remains open, it's easy enough to do that. If the form is
called Form1, and the text box is named Textbox1, you can set the Control
Source of a text box on your report to:
=[Forms].[Form1].[Textbox1]

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Roger said:
Thanks for getting back to me. I understand what you have said,
however my application is a bit different (I'll bet they all say
that). The company that I work for is into "metrics" which is a
measurement of the efficiency of a process. I have a database
of customer requested operations that were performed by my
organization over a period of time. In order to develop the
"metrics" for this particular process, I have to pick a given
month and then calculate/print things like average turn-around
time, average labor hours, average cost, quantity of requests
received, quantity of requests canceled, quantity of requests
completed, quantity of requests still active by the end of the
month (backlog).

Calculating these quantities is fairly straight forward and it's
done in the Form after the user enters the from/to dates for the
calculation. The next step is to print the information on a
formatted Report. What I have been doing in cases like this is
to create a 1-record table with fields that match the quantities
to be printed. From the Form, I stuff the table and then call
on the Report to do the printing. The Report reads the data
from the single record in the table, populates the Report, and
then prints the Report.

It seems to me that it would be a lot more efficient to simply
send the memory variables directly over to the Report rather
than out to the disk first in the single record table and then
back to the Report. This means that I would have to link
objects in the Report to memory variables rather than to fields
in a table. Can this be done?

Thanks,
Roger


You would normally create a query to act as the RecordSource for
the report.

You can type calculations into the Field row in a report. For
example, if
the due date is 30 days after the invoice date:
DueDate: DateAdd("d", 30, [InvoiceDate])

Another example from the Invoices query that feeds the Invoices
report in
the Northwind sample database:
ExtendedPrice: CCur([Order
Details].UnitPrice*[Quantity]*(1-[Discount])/100)*100

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Roger said:
I've seen the argument that one should print from a Report and
not from a Form. OK, I give up. I'll do all my printing from
Reports.

That said, is it possible to populate a Report with public
variables calculated in a Form rather than from the fields of
a
table on a disk? I have many occasions to do this. In my
limited knowledge of VB in Access 2000, I'm currently having
to
create special tables populated from within a Form and then
fed
to a Report. This means undesired reads and writes to a disk
rather than dealing strictly with memory variables which would
be much more efficient.

If it can be done, how do I do it?

Thanks,
Roger
 
Bingo!

That's what I was looking for. It worked like a charm.

Thank you so much.

Roger



So you already have the results you want in text boxes on your
form, and you
want to print a report that refers to those values?

Assuming the form remains open, it's easy enough to do that. If
the form is
called Form1, and the text box is named Textbox1, you can set
the Control
Source of a text box on your report to:
=[Forms].[Form1].[Textbox1]

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Roger said:
Thanks for getting back to me. I understand what you have
said,
however my application is a bit different (I'll bet they all
say
that). The company that I work for is into "metrics" which is
a
measurement of the efficiency of a process. I have a database
of customer requested operations that were performed by my
organization over a period of time. In order to develop the
"metrics" for this particular process, I have to pick a given
month and then calculate/print things like average turn-around
time, average labor hours, average cost, quantity of requests
received, quantity of requests canceled, quantity of requests
completed, quantity of requests still active by the end of the
month (backlog).

Calculating these quantities is fairly straight forward and
it's
done in the Form after the user enters the from/to dates for
the
calculation. The next step is to print the information on a
formatted Report. What I have been doing in cases like this
is
to create a 1-record table with fields that match the
quantities
to be printed. From the Form, I stuff the table and then call
on the Report to do the printing. The Report reads the data
from the single record in the table, populates the Report, and
then prints the Report.

It seems to me that it would be a lot more efficient to simply
send the memory variables directly over to the Report rather
than out to the disk first in the single record table and then
back to the Report. This means that I would have to link
objects in the Report to memory variables rather than to
fields
in a table. Can this be done?

Thanks,
Roger


You would normally create a query to act as the RecordSource
for
the report.

You can type calculations into the Field row in a report. For
example, if
the due date is 30 days after the invoice date:
DueDate: DateAdd("d", 30, [InvoiceDate])

Another example from the Invoices query that feeds the
Invoices
report in
the Northwind sample database:
ExtendedPrice: CCur([Order
Details].UnitPrice*[Quantity]*(1-[Discount])/100)*100

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Roger said:
I've seen the argument that one should print from a Report
and
not from a Form. OK, I give up. I'll do all my printing
from
Reports.

That said, is it possible to populate a Report with public
variables calculated in a Form rather than from the fields of
a
table on a disk? I have many occasions to do this. In my
limited knowledge of VB in Access 2000, I'm currently having
to
create special tables populated from within a Form and then
fed
to a Report. This means undesired reads and writes to a disk
rather than dealing strictly with memory variables which
would
be much more efficient.

If it can be done, how do I do it?

Thanks,
Roger
 
Back
Top