Prev: Run Time Error 429
Next: Filter Form on Combo Variable
From: robeito on 10 May 2010 12:23 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 10 May 2010 13:35 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 10 May 2010 14:16 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 10 May 2010 14:22 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 11 May 2010 09:11
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 > > |