Public functions, easy question 
Author Message
 Public functions, easy question

I have code attached to a button on one form.  I wrote a function that
this button called that I declared as Public Function
calc_results(parameter).  Now I want to use this function from another
form. How do I do this?  When I just call the function, I get an unknown
function compile error.  If I try to declare it, it wants me to specify
a library and I have no idea how to set that up.  I looked at the object
browser, but cannot figure out what I am supposed to do.  Please help.


Sun, 21 Dec 2003 01:20:08 GMT  
 Public functions, easy question
Take the function/procedure out of your form module and put it in a Module.

Public Sub calc_results(argument as DataType)
    ...
    ...
End Sub

You can then call your function/procedure from any module in your
application.

RJ


Quote:
> I have code attached to a button on one form.  I wrote a function that
> this button called that I declared as Public Function
> calc_results(parameter).  Now I want to use this function from another
> form. How do I do this?  When I just call the function, I get an unknown
> function compile error.  If I try to declare it, it wants me to specify
> a library and I have no idea how to set that up.  I looked at the object
> browser, but cannot figure out what I am supposed to do.  Please help.



Sun, 21 Dec 2003 02:29:52 GMT  
 Public functions, easy question

writes:

Quote:
>I have code attached to a button on one form.  I wrote a function that
>this button called that I declared as Public Function
>calc_results(parameter).  Now I want to use this function from another
>form. How do I do this?  When I just call the function, I get an unknown
>function compile error.  If I try to declare it, it wants me to specify
>a library and I have no idea how to set that up.  I looked at the object
>browser, but cannot figure out what I am supposed to do.  Please help.

As well as declaring the function as Public, you must also make sure that it is
available to Access. If the form that has this function in is not open when you
try to run the function, you will get an error. The best thing to do is to
remove your function from where it is at the moment, and place it in a
standalone module, where it will be accessible from all forms in your database.

Jon

Access tips & tricks - http://www.applecore99.com
Microsoft Access webring -
http://nav.webring.yahoo.com/hub?ring=microsoftaccess



Sun, 21 Dec 2003 02:44:16 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. EASY EASY EASY question

2. Public function with public-object parameter

3. Passing Public user-defined types via Public Functions

4. Using UDT as parameter in public sub or public function

5. Private & Public Subs/Functions Question

6. easy question - date function syntax?

7. Easy question, the Replace function !

8. Calling Function in CBF from Toolbar via a Public Function

9. help easy easy question

10. easy filecopy question...but maybe not so easy

11. Exposing public functions without exposing everything

12. Modules and Public Functions

 

 
Powered by phpBB® Forum Software