OnKeyDown Event Expression

D

dchman

I have an app for which one requirement is to add controls to a form
dynamically. For some of the controls, I set the OnMouseDown event to an
expression;

strExpr = "[Forms]![frmDisplay]![" & ctl.Name & "]"
ctl.OnMouseDown = "= SetCurCtrl(" & strExpr & ")"

Essentially the expression calls the function "SetCurCtrl" with a reference
to itself.

At run time, after the form is built, it is presented to the user. If the
user clicks one of the controls, the MouseDown event fires the expression.

I also want to dynamically code the OnKeyDown event to call a function which
takes the control reference and the KeyCode for the key which triggers the
event. However, when writing the code to dynamically create the expression,
I don't know how to refer to the KeyCode for the triggering key. Can anyone
point me in the right direction?

thanks
 
K

Klatuu

The first point I would suggest is try to find another way to do this. There
is a lifetime limit of about 750 controls for a form. Each time a user
dynamically creates a control, it adds to the count, but it does not subtract
when the form is closed or the control deleted.

It may be better to create the controls that the user may need and make them
invisible, no tabl stop, no tool tip, ect., so they would not know it is
there. Then when they need the control, set the properties in your code to
make it work like you want it.
 

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