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!

Why can't the space key act normal on KeyUp?

Status
Not open for further replies.

boxboxbox

Technical User
Apr 22, 2003
108
US
I'm using a textbox to filter a subform, using the KeyUp event to refresh the query, and the space key won't respond. It will refresh the query, but immediately delete the space I just entered. I can trap the space key using the case is: (Case Is = 32 ' space) which allows me to type the space key and the space will show up.

HOWEVER, this does not refresh the query, so my subform is not further filtered until I type a letter. Is there a way to make the space key simply act like a normal letter key?

Thanks.
 
VB has chosen to make spaces invisible. Catch you space and set it to some value that the following code can find.

Sometimes to know why just costs toooooo much.



Rollie E
 
Thank you. That sounds logical, but unfortunately I don't know exactly how to do so. What value could I use instead? I don't want any numbers/letters/symbols to show up, as that would be confusing to the user.

Here is my code. Would I put it before the "select case keycode" or right before the "dim stDocName As String"?

Thanks again...I've been too busy to get back to this for awhile

Code:
Select Case keycode
    
    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 = 32   ' space
    
   
    Case Else
    
        'Your code to respond to all other keys here

On Error GoTo Err_ShipFilter_KeyUp
    
    Dim stDocName As String
    nPos = ShipFilter.SelStart
    stDocName = "OpenStuff.Requery"
    DoCmd.RunMacro stDocName
    ShipFilter.SetFocus
    ShipFilter.SelStart = nPos
 
I tried using:

nPos = nPos + 1

once I captured the space key, and it will still move to the right one space, but it won't refresh my query, even if I send the code straight to that requery line. Do I need to add a criterium to my select query?

Sigh...

Stupid "unnormal" spaces...
 
ah ha! In the query I added

Like " " & forms!myform!shipfilter & " ". And this makes it work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top