accde - Report design

A

Andy

Hi,

I have some VBA that modifies a report's design.


However, the code throws an exception on this line:

DoCmd.OpenReport rpt_name, acViewDesign


I understand the reason why, so here's my question:

Q) How can my VBA code modify a report in an accde file?


Thanks
 
R

Rick Brandt

Andy said:
Hi,

I have some VBA that modifies a report's design.


However, the code throws an exception on this line:

DoCmd.OpenReport rpt_name, acViewDesign


I understand the reason why, so here's my question:

Q) How can my VBA code modify a report in an accde file?

Opening in design view would only be required if you want to make a
permanent change and no, you cannot do that at all in an mde/accde.
However; you can run code in the various events of the Report to make on-
the-fly changes that are temporary to that report instance or section
processing. This would not allow all of the types of changes that could be
done in design view, but quite a bit is still possible.

What exactly are you wanting to do?
 
D

David W. Fenton

I have some VBA that modifies a report's design.

Why? This is a terrible idea, and almost surely a mistake.
However, the code throws an exception on this line:

DoCmd.OpenReport rpt_name, acViewDesign


I understand the reason why, so here's my question:

Q) How can my VBA code modify a report in an accde file?

I'm going to answer your question with a question;

Q) Why do you think you need to modify the report design at runtime?
I've been programming in Access for over 14 years and never once
found a need to do that (or even contemplated).

Explain what you're trying to accomplish and my bet is that there's
a 99.99% chance that it can be done without modifying the report's
design.
 
L

Larry Linson

If you have the same problem, then it stands to reason the answer is the
same.

My question would be: what are you doing that makes it necessary to modify
the design of a report at runtime. I only ask because I've been using
Access daily since early 1993 and have never encountered a situation where
that is a necessity.

If you'd explain what data you have, how it's structured, and what you want
to accomplish (not how you want to accomplish it), it's entirely possible
that someone might be able to offer a useful suggestion.

Oh, and that would also apply to the original poster in this thread.

Larry Linson
Microsoft Office Access MVP

jero said:
Hello,
I have the same problem... and I create several reports...
 
A

Andy

Thanks Rick,

This is precisely what I needed to know.


I have already used a report's events for formatting, so I'm ready to go.

Thanks so much for your time.


Andy
Opening in design view would only be required if you want to make a
permanent change and no, you cannot do that at all in an mde/accde.
However; you can run code in the various events of the Report to make on-
the-fly changes that are temporary to that report instance or section
processing. This would not allow all of the types of changes that could be
done in design view, but quite a bit is still possible.

What exactly are you wanting to do?

FYI For Larry and David, too:

I need to format the report on the fly for several reasons, 2 being:

1) I have the same report that could be printed in different languages. They
would look awful if I didn't format them properly. Creating many reports only
wastes time when I update a report a few months/years later.

2) One report could have three levels of "security": All information,
general internal usage, and for the public

Having one report and using code to hide/show sensitive areas saves so much
time. Of course the report would need a little formatting to keep them
looking good after some controls/sections have been hidden.
 

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