Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Call Form's public function from report (2003 issue)

Status
Not open for further replies.

KMKelly

Programmer
Jan 23, 2002
35
0
0
US
This is sort of a half theory/half practical question. I didn't even know this was possible previously. I just learned it was possible from someone else's design to call a public function that is embedded in a form from a report (learn something new everyday). It looks just like calling a field/control really. Forms!frmName.functionname in a field on the report.

The problem is it doesn't work in 2003 unless security is set to low.

I know how I would have done that same thing (basically filling in the descriptive text portion of various dropdown criteria fields on the form as report criteria labels). The report should only be open when the form is, so I would directly call the field and perform any cleanup or other stuff directly in the calculated field in the report.

Code:
 IIf(Forms!frmBillDialog!Billarea=999,"All Divisions",StrConv(Right(Forms!frmBillDialog!BillArea.Column(1),(Len(Forms!frmBillDialog!BillArea.Column(1))-4)),3))

My question:
For anyone more familiar with this way of approaching things, is there a benefit to doing it using the functions in that manner? Is there a way to make it work in 2003 at the medium security setting (what doen't it like about it)? What about doing a general module function that you feed in the form name - would it cause the same problem?

Thanks.
Kris
 
I just learned this concept as well, but there is far more to it, and it has changed the way I program. A form's module is a class module like any other class module. So if you understand this, there are many things that you can do that you may not have thought of. So the reason you can call the public function, is the same as calling any public function of a class. Other things you can do include:
1) Creating multiple intances of a form
2) Defining custom events
3) Defining your own properties (let, set, get)

I have been using the Access 2002 Desktop Developer's Handbook (Litwin, Getz, and Gunderloy) and it has very good discussion and examples of using Form class modules. If you are not coding this way now, I would recommend taking a look.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top