how to use vba inside a report

M

mg

I have a report, based on a query. works fine.
i want to do 2 things:
1) before the report is generated, i want to look through the recordset and
delete certain records(cant do it in the query - way too many what-ifs)
2) after the report is generated, i want to NOT show sections of detail and
footers if the section total is $0

not sure how to get started.
THANKS!
mike g
 
A

Allen Browne

That's not going to work.

At worst, create a temporary table with the fields you need for the report.
Execute a Delete query to remove any records in there from last time. Then
execute an Append query to add the records you want. At this point, you can
remove any records you don't want. Then base the report on this temporary
table.

While it is possible to use VBA in the Format event of the report's sections
(such as Detail), doing so yields unreliable results and weird problems.
This is because the events fire only for the pages Access actually
calculates. So ifyou preview and ask it to print just page 6 of the report,
you get different records printed than what you would get on page 6 if you
printed the whole report. You may end up with a report where the last page
is "Page 11 of 8." And any totals you calculate in the report events are
unreliable (may be the wrong values.)

Depending on what you are doing, there may be simpler solutions than the
temporary table. For example, you might be able to use a Totals query to
choose the records that have a non-zero value, and then use a subreport to
show the details.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top