Using a Public Function

  • Thread starter Thread starter LeLe
  • Start date Start date
L

LeLe

I found a great function to allow me to display my decimals as fractions, but
I don't know how to use it? I create reports which then become either work
tickets or finished product labels. Where do I put the code. I understand
the idea that it should be public so I can use it in any part of my
application, but how do I refer to it?
Thanks so much.
 
I found a great function to allow me to display my decimals as
fractions, but I don't know how to use it? I create reports which
then become either work tickets or finished product labels. Where
do I put the code. I understand the idea that it should be public
so I can use it in any part of my application, but how do I refer
to it? Thanks so much.

Go to the modules tab of the database window. click new. Paste the
code, make sdure the function's definition uses the public keyword
in its definition.

e.g. Public Function ShowAsFraction(byval number2show as variant) as
variant

save the module with a name that's similar to your function's name,
but prefixed with mdl, e.g. mdlShowAsFraction.

To use the function you call it like any other function in Access
=ShowAsFraction(2.5)
 
Thanks, but I am still unclear. I want all of my reports which are used as
worktickets to automatically display numbers in the fraction format.
Currently, I am using the on format event of the report detail to hide and
unhide certain fields depending on various criteria. Can I use the function
here? Do I have to apply the function to each number control in the report
separately? Obviously I would prefer to do it once for the entire
application. Sorry, I probably should know the answer to this ... but I don't

Thanks again.
 
Thanks, but I am still unclear. I want all of my reports which
are used as worktickets to automatically display numbers in the
fraction format. Currently, I am using the on format event of the
report detail to hide and unhide certain fields depending on
various criteria. Can I use the function here? Do I have to
apply the function to each number control in the report
separately? Obviously I would prefer to do it once for the entire
application. Sorry, I probably should know the answer to this ...
but I don't

Thanks again.

yes, you'd have to use the function separately against each control
you wish to format in this fashion. And you can use the function in
the on format of a report, if it's applicable.
 

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

Back
Top