Using immediate window

L

Lars Brownies

When I make a function (public or private) that belongs to a form, I can't
execute it in the immediate window like:

?fMyFunction("Testvalue"), or
Call fMyFunction("Testvalue)

With a sub the ?sMySub does work and in a module the above function calls
both work.

Is this expected behavior? What am I missing?

Thanks,
Lars
 
T

Tom van Stiphout

On Sun, 31 Jan 2010 22:37:06 +0100, "Lars Brownies"

This is indeed expected. Procedures (functions and subs) in modules
are globally available, and those in forms (and reports) only when the
form is open. While open, your technique can run public procedures in
the form.

-Tom.
Microsoft Access MVP
 
S

Stefan Hoffmann

hi Lars,

When I make a function (public or private) that belongs to a form, I
can't execute it in the immediate window like:

?fMyFunction("Testvalue"), or
Call fMyFunction("Testvalue)

With a sub the ?sMySub does work and in a module the above function
calls both work.

Is this expected behavior? What am I missing?
Yes, Tom is right.

he reason is quite simple:
The code behind a form is threated like class code. Conceptual it's the
quite the same, just an specialized version of a class module.
Thus you have to instantiate the form first - before calling a public
method of this form. So you can execute it when the form is open.


mfG
--> stefan <--
 
L

Lars Brownies

Thanks, both.

Lars

Tom van Stiphout said:
On Sun, 31 Jan 2010 22:37:06 +0100, "Lars Brownies"

This is indeed expected. Procedures (functions and subs) in modules
are globally available, and those in forms (and reports) only when the
form is open. While open, your technique can run public procedures in
the form.

-Tom.
Microsoft Access MVP
 

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

Top