I'm sure you're correct, if only I knew how (I have tried all kinds of
variations on your code theme), or what was going wrong with this code, but
this:
Private Sub Combo_Answer_KeyUp(KeyCode As Integer, Shift As Integer)
If (KeyCode = 191) Or (KeyCode = 111) Then
Me.txt_Run_point_Address.Visible = Not Me.txt_Run_point_Address.Visible
Me.Run_Point_Postcode.Visible = Not Me.Run_Point_Postcode.Visible
KeyCode = 0
End If
End Sub
Together with this:
Private Sub Combo_Answer_KeyPress(KeyAscii As Integer)
If KeyAscii = 47 Then
KeyAscii = 0
End If
End Sub
will show the text box, but when I release the key, it will not hide it
until i press the key again.
However, If use this as well (when I have read the visible answer box and
want to move to the next question/record):
Private Sub Combo_Answer_LostFocus()
Me.txt_Run_point_Address.Visible = False
Me.Run_Point_Postcode.Visible = False
End Sub
Then the text box once again becomes invisible (without having to hit/toggle
the '/' key again)
It's not ideal, but I just can't figure out why something so simple as, If I
press this key, show the box, and when I release the key, just hide it.
I didn't really understand what you were getting at when you said "I'm not
sure this is a great way to design an app in a multi-tasking environment." I
am guessing that there is some relevenance to the 'multi-tasking
environment', but I don't really understand the context in which you say it?
regards
Eric
Allen Browne said:
I'm sure you can take what I suggested, and adapt it so that the KeyPress
shows and the KeyUp hides the text box.
I'm not sure this is a great way to design an app in a multi-tasking
environment.
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Reply to group, rather than allenbrowne at mvps dot org.
efandango said:
Allen,
I tried it, and it works as you describe; but the problem is that I don't
want to have to manually toggle it on/off; instead I want this sequence to
occur.
1. press the / key and hold it (makes the text visible)
2. digest the answer and eventually release the key (makes text box
invisible)
that's it.
but with your current code:
1. I press the / key (reveals the text)
2. release the key (still reveals text)
3. press key again (hides text)
this requires two hits of the '/' to toggle on/off, when I really need the
toggle off to be automatic, by simply releasing the '/' key. can this be
done?
Allen Browne said:
I just tried this in an unbound text box (Text27), and it toggled the
Surname text box's visible property when you release the key:
Private Sub Text27_KeyUp(KeyCode As Integer, Shift As Integer)
If (KeyCode = 191) Or (KeyCode = 111) Then
Me.Surname.Visible = Not Me.Surname.Visible
KeyCode = 0
End If
End Sub
Private Sub Text27_KeyPress(KeyAscii As Integer)
If KeyAscii = 47 Then
KeyAscii = 0
End If
End Sub
Using KeyPress destroys the keystroke, and the KeyUp means it doesn't
repeat.
Stuart,
that seemed to work on the repeating key issue, but for some reason the
KeyUp command doesn't work, in so much as the following code no longer
makes
the text box non-visible, until I move to a neww record?. Can it be
made
such
that the KeyDown button makes the textbox visible, and the KeyUp makes
it
invisible, just like it did on the command button that I mentoned on my
first
posting.
This is what I have so far:
KeyDown:
Select Case KeyCode
Case vbKeyDivide, 191
Me![txt_Run_point_Address].Visible = True
Me![Run_Point_Postcode].Visible = True
KeyCode = 0
End Select
KeyUp:
Me![txt_Run_point_Address].Visible = False
Me![Run_Point_Postcode].Visible = False