Handling "Shift" Key

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello:

Is there a way I can make a particular control on a form visible only if the
SHIFT key is held down while opening the form? If the SHIFT key is not
depressed when the form is opened, then that control should be not visible.
I wasn't having too much luck with this. Any assistance with this question
will be most welcome. Thank you in advance.

Amar
 
Amar said:
Hello:

Is there a way I can make a particular control on a form visible only
if the SHIFT key is held down while opening the form? If the SHIFT
key is not depressed when the form is opened, then that control
should be not visible. I wasn't having too much luck with this. Any
assistance with this question will be most welcome. Thank you in
advance.

Amar

Your normal startup code could set a public variable (HideMyControl) to
True. The Open event of the form would use...

Me.ControlName.Visible = Not HideMyControl

If you hold the shift key while opening the file the startup code doesn't
run therefore HideMyControl will be False and the control will be visible
when the form is opened. Beware though that in an MDB a public variable can
lose its value on an untrapped error. You could use a control on a hidden
form or a custom database property instead of a public variable if you are
concerned about that.
 
Back
Top