From: robeito on
Hello everybody:

Actual situation of my form:
onKeyDown= "[Event procedure]"

Desired situation:
onKeyDown= "myFunction"

I know that myFunction must be in a module, and must be public. But
I don't know the syntax for doing this !

I want to call myFunction from a lot of forms in my application, so, I want
to write it only once.
Also, I want to use the parameters KeyCode and Shift that uses the regular
call of the event.

Thanks in advance


From: Daryl S on
Robeito -

Leave the [Event procedure] there and click on the elipses to the right of
it (...). That will open up the code window for that event. In that code
window is where you will put your function call.

The function call will usually look something like this, depending on what
you need passed in and what you return from the function:

varReturnedValue = myFunction(passIn1, passIn2)

where passIn1 would be the first argument passed in to the function (if
there are any), etc.

--
Daryl S


"robeito" wrote:

> Hello everybody:
>
> Actual situation of my form:
> onKeyDown= "[Event procedure]"
>
> Desired situation:
> onKeyDown= "myFunction"
>
> I know that myFunction must be in a module, and must be public. But
> I don't know the syntax for doing this !
>
> I want to call myFunction from a lot of forms in my application, so, I want
> to write it only once.
> Also, I want to use the parameters KeyCode and Shift that uses the regular
> call of the event.
>
> Thanks in advance
>
>
From: robeito on
Thanks Douglas
Your example works fine. Actually I'm trying something like this:

onKeyDown= "=myFunction(keycode,shift)"

but Access changes this to "=myFunction([keycode],[shift])"
and the calling is not working


From: robeito on
Thanks Jon

Your comment is clear to me, but I would like to write no extra code in the
VBA window so maybe I sould try creating a class to handle the form's events


From: Daryl S on
Robeito -

Tell us what 'not working' means, and include your myFunction code, at least
the header. If you step through the code, what happens?

--
Daryl S


"robeito" wrote:

> Thanks Douglas
> Your example works fine. Actually I'm trying something like this:
>
> onKeyDown= "=myFunction(keycode,shift)"
>
> but Access changes this to "=myFunction([keycode],[shift])"
> and the calling is not working
>
>
 |  Next  |  Last
Pages: 1 2
Prev: Run Time Error 429
Next: Filter Form on Combo Variable