By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,385 Members | 1,115 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,385 IT Pros & Developers. It's quick & easy.

Access 2002: Call VB module from reports

P: n/a
D.M
Hello,
Do you know what is the best way to call VB modules from reports.
Thanks in advance.
Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies

P: n/a
"D.M" <no****@hotmail.com> wrote in news:bs**********@ariane.blic.net:
Hello,
Do you know what is the best way to call VB modules from reports.
Thanks in advance.


Reports are strange animals and where to call procedures may depend on what
the procedure is going to do. One of the more effective ways seems to be to
put the call in the event code of the report or one of its sections. If the
code is to impact the report's recordsource or filter, it may be useful to
set the appropriate property of the report to a call to the procedure, eg:
InputParamaters = GetThisReportsInputParameters()
In ACXP (and greater one assumes) one can set the report's recordset to an
ADO recordset and do some interesting things in the section onformat events,
but this doesn't seem to be documented and it requires some trial and error
work.
--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #2

P: n/a
D.M previously wrote:
Hello,
Do you know what is the best way to call VB modules from reports.
Thanks in advance.

Reports have events and so have event procedures just like every other
object. So in theory coding in reports is no different to coding anywhere
else.
Unfortunately report events occur at uncontrollable and
unpredictable frequencies so your code must be written to produce the
correct answer no matter how many times it might run - which is well nigh
impossible for anything beyond basic assignment and formatting.

Regards

Peter Russell
Nov 12 '05 #3

P: n/a
Certainly, you have to protect yourself from multiple firings of the event
if you are doing calculations. If you are just setting some properties, then
it may not matter if the code is executed more than once (and that is a
common use of code in events -- if FieldX is a certain value, show/don't
show some Text Box by setting its Visible property, for example).

If you want to change the RecordSource of the Report, that must be done in
the Open event.

Larry Linson
Microsoft Access MVP

"Peter Russell" <ru***@127.0.0.1> wrote in message
news:me**********************@russellscott.btinter net.com...
D.M previously wrote:
Hello,
Do you know what is the best way to call VB modules from reports.
Thanks in advance.

Reports have events and so have event procedures just like every other
object. So in theory coding in reports is no different to coding anywhere
else.
Unfortunately report events occur at uncontrollable and
unpredictable frequencies so your code must be written to produce the
correct answer no matter how many times it might run - which is well nigh
impossible for anything beyond basic assignment and formatting.

Regards

Peter Russell

Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.