controlling invisible controls on form

R

Rajtomar

I have a form with some fields invisible (these fields are kept to
pass values when required for arithmatic calculations) I am looking
for a code which will scan my keyboard strokes and when i press a key
combinations (custom 3 or 4 keys) that time the invisble field should
become visible and as soon as i leave the keys the field should again
get invisible.

thanks
 
P

Piet Linden

I have a form with some fields invisible (these fields are kept to
pass values when required for arithmatic calculations) I am looking
for a code which will scan my keyboard strokes and when i press a key
combinations (custom 3 or 4 keys) that time the invisble field should
become visible and as soon as i leave the keys the field should again
get invisible.

thanks

check out KeyPress and KeyDown
 
R

Rajtomar

can you give some sample code for an invisible control to become
visible by pressing two keys
 
L

Linq Adams via AccessMonster.com

This code allows you to toggle visibily of a set controls:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim intCtrlDown As Integer

intCtrlDown = (Shift And acShiftMask) > 0

If intCtrlDown And KeyCode = vbKeyS Then
If HiddenTextBox1.Visible = True Then
HiddenTextBox1.Visible = False
HiddenTextBox2.Visible = False
Else
HiddenTextBox1.Visible = True
HiddenTextBox2.Visible = True
End If
End If
End Sub

Assumming the textbox Visible Properties are set o No, in Design View,
pressing <Shift> + <S> causes the textboxes to become visible.

Pressing <Shift> + <S> a second time causes them to be hidden again.

You could use <Alt> + <Another key> or <Ctrl> + <Another key> by substituting


acShiftMask

with

acAltMask or acCtrlMask. You also can change the letter key, vbKeyS in this
case, with any other alpha key.

Note that while you can do these key combos using <Ctrl> or <Alt>, <Ctrl> is
used for shortcuts for menu items, and <Alt> is used for developer assigned
shortcuts to command buttons, so <Shift> is probably the best to use.
 
L

Linq Adams via AccessMonster.com

This code allows you to toggle visibily of a set controls:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim intCtrlDown As Integer

intCtrlDown = (Shift And acShiftMask) > 0

If intCtrlDown And KeyCode = vbKeyS Then
If HiddenTextBox1.Visible = True Then
HiddenTextBox1.Visible = False
HiddenTextBox2.Visible = False
Else
HiddenTextBox1.Visible = True
HiddenTextBox2.Visible = True
End If
End If
End Sub

Assumming the textbox Visible Properties are set o No, in Design View,
pressing <Shift> + <S> causes the textboxes to become visible.

Pressing <Shift> + <S> a second time causes them to be hidden again.

You could use <Alt> + <Another key> or <Ctrl> + <Another key> by substituting


acShiftMask

with

acAltMask or acCtrlMask. You also can change the letter key, vbKeyS in this
case, with any other alpha key.

Note that while you can do these key combos using <Ctrl> or <Alt>, <Ctrl> is
used for shortcuts for menu items, and <Alt> is used for developer assigned
shortcuts to command buttons, so <Shift> is probably the best to use.
 
R

Rajtomar

Thanx Linq Adams it worked exactly as i wanted thanx a lot. Also it
would have been good if you could tell me to use a combination of keys
may be 3 or 4.

Anyways. thanx a lot
 

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