How cmd btn on tools bar refer private function

S

suntisuk

Can Command button on tools bar link Action to private
function on the form that display tools bar ?

If it link to only public function, How can my Command
button refers to a lot of variables those be used in that
function ?

TIA
 
D

Dirk Goldgar

suntisuk said:
Can Command button on tools bar link Action to private
function on the form that display tools bar ?

If it link to only public function, How can my Command
button refers to a lot of variables those be used in that
function ?

TIA

It can't be a private function. It must be public, though it can be
defined in the form's module. However, in my test of this just now, I
found the function I was invoking via the OnAction expression

=Forms("Form22").TestMyForm

fired twice whenever I clicked the button. I don't know why that is.
But when I created a function in a standard module, like this:

Function TestFormMethod()
Call Forms("Form22").TestMyForm
End Function

and then set the button's OnAction expression to call that function:

=TestFormMethod()

the function only fired once.
 
S

Stephen Lebans

This is a kown bug/feature Dirk. I think someone posted a solution a few
months back wither in the private MVP NG or over in CDMA.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
D

Dirk Goldgar

Now that you mention it, I do seem to recall reading something about it
before. I don't remember what the solution may have been, but the
expedient of putting a helper function in a standard module seems simple
enough. Or use a macro to call the function.
 
M

Marshall Barton

Dirk said:
Now that you mention it, I do seem to recall reading something about it
before. I don't remember what the solution may have been, but the
expedient of putting a helper function in a standard module seems simple
enough. Or use a macro to call the function.

I vaguely remember that thread too, but after searching I
couldn't find it. I'm really reaching here, but I think it
concluded that you should not use
=Forms!theform.thefunction() in the action. Something
about, **if the form has the focus**, its methods are used
before searching for a standard module function, so you
should just use =thefunction()
 

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