Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

KeyUp recognizes arrow keys! How to stop? 1

Status
Not open for further replies.

boxboxbox

Technical User
Apr 22, 2003
108
US
I'm using a textbox to filter a form (thanks flo79!). I have the KeyUp event set for this textbox, so the filter is based on what is typed into the textbox and changes with every keystroke.

However, the KeyUp event recognizes the arrow keys, and I don't want it to (I want to be able to navigate through the text to fix spelling errors, etc).

Anyone know code to set the KeyUp to NOT recognize the arrow keys?

Thanks
 
I think you have to recognise the key up - and capture which key it is and then only respond with the filter modification if the key is not an arrow key.




G LS
accessaceNOJUNK@valleyalley.co.uk
Remove the NOJUNK to use.
 
Thanks. That may be it, but I'm not sure I know how to do that... Do I use the KeyPress to retrieve what key(I've seen some other threads for this)--using the ANSI? Then how do I put any of that into the filter/query criteria?
 
Try this

Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case Is = 8 ' Ignore Backspace
Case Is = 13 ' Ignore Return Key - If appropriate
Case Is = 37 ' Ignore Left Arrow
Case Is = 38 ' Ignore Up Arrow
Case Is = 39 ' Ignore Right Arrow
Case Is = 40 ' Ignore Down Arrow
Case Is = 46 ' Ignore Delete
Case Else
'Your code to respond to all other keys here

End Select

End Sub




'ope-that-'elps.




G LS
accessaceNOJUNK@valleyalley.co.uk
Remove the NOJUNK to use.
 
Oh you're the best! Thank you. That works perfectly.
 
By the way, the spacebar seems to be only half-recognized as a valid data key (like a letter) but I need it to be fully recognized. Basically my form seems to re-evaluate the code, but it won't actually put a space in my text box. It immediately deletes the space.

Can I add/change this somehow in the Case Else code?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top