Results 1 to 4 of 4

Thread: KeyPress issues

  1. #1
    2 Star Lounger
    Join Date
    May 2001
    Location
    indiana
    Posts
    130
    Thanks
    0
    Thanked 0 Times in 0 Posts

    KeyPress issues

    hi all
    what i have is a text box for entering info, and a command button for adding the text in the box to a list. i would like to enable the add button when there is something in the text box. i would like to check for info after each key press, but i can't get the code to check at the right time. on key up, the value of the text box (after i type a letter in, for example) is still "". any help would be appreciated..

    thanks

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: KeyPress issues

    Hi Andy,
    Try checking the Text property of the text box rather than the Value and you should be able to detect whatever's in the textbox.
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    2 Star Lounger
    Join Date
    May 2001
    Location
    indiana
    Posts
    130
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: KeyPress issues

    thanks rory
    didn't even know that property existed (been programming for over a year).. are there better times to use the text property over the value property?

    thanks

  4. #4
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: KeyPress issues

    It depends what you're after really. The Text property will always give you what's visible in the text box at the time whereas the Value property will of course give you the stored value. For example, if you have a textbox control on a form bound to a name field which contains "John" for the current record and you start typing "Jim" over the top, the text property will change from "J" to "Ji" to "Jim" as you type but until that control updates the record, the Value will remain "John". Incidentally, rather than using KeyUp you could use the Change event of the control to monitor the changing text.
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •