public function not recognized by another form.... 
Author Message
 public function not recognized by another form....

--It was my understand that if I declare a function with as Public in one
form's code then it is available for use in a different form.  But when I
call that Public function from another form I get an error stating that the
function is not defined.  As a temporary workaround, I have had to copy the
function into each form that will call it but this is obviously redundant
and should be avoidable if I could get the damn Public statement to
work....help!

Thanks,
MA



Wed, 26 Sep 2001 03:00:00 GMT  
 public function not recognized by another form....
It is avaialble.  However, you have to call it as a method of the form in which
it is declared.  For example, if you have a function called TestFunction()
declared as Public in Form1, you can access it from any other form or module as
follows:.

y = Form1.TestFunction(x)

John...........

Quote:

> --It was my understand that if I declare a function with as Public in one
> form's code then it is available for use in a different form.  But when I
> call that Public function from another form I get an error stating that the
> function is not defined.  As a temporary workaround, I have had to copy the
> function into each form that will call it but this is obviously redundant
> and should be avoidable if I could get the damn Public statement to
> work....help!

> Thanks,
> MA



Wed, 26 Sep 2001 03:00:00 GMT  
 public function not recognized by another form....

Quote:

>--It was my understand that if I declare a function with as Public in one
>form's code then it is available for use in a different form.  But when I
>call that Public function from another form I get an error stating that the
>function is not defined.  As a temporary workaround, I have had to copy the
>function into each form that will call it but this is obviously redundant
>and should be avoidable if I could get the damn Public statement to
>work....help!

>Thanks,
>MA

Be sure to preface the call with the form name. For instance when calling
Function1 from Form2;

Form1------

Public Function Function1(strOut as String)
    Debug.Print strOut
End Function

Form2------

'call to Function1
Form1.Function1 "some stuff to print"

--
yabba
===========================
yabbadoo<at>bigfoot<dot>com



Thu, 27 Sep 2001 03:00:00 GMT  
 public function not recognized by another form....

Quote:
> --It was my understand that if I declare a function with as Public in one
> form's code then it is available for use in a different form.  But when I
> call that Public function from another form I get an error stating that the
> function is not defined.  As a temporary workaround, I have had to copy the
> function into each form that will call it but this is obviously redundant
> and should be avoidable if I could get the damn Public statement to
> work....help!

The way I do it (and it was recommended to me) was to add a .bas
module to your project and add all your public functions to it.
Then you can access those functions from any form at any time.

You can also use the .bas module in all your projects (which you
couldn't do if you had your public functions in a form).

Works great!  :)

Otser.



Fri, 28 Sep 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. public function not recognized by another form....

2. Public Types not recognized in Dynamic Modules

3. Public Type Variable not Recognized in dynamic module

4. Procedure in class does not recognize public event

5. User defined function not recognized

6. Trim Function Not Recognized?

7. function names not recognized in Access 97

8. Format function not recognized

9. Access 7.0 does not recognize VBA functions

10. Access not recognizing string functions

11. Left$, Right$ function not recognized in another computer.

12. Word can not recognize VBA function.

 

 
Powered by phpBB® Forum Software