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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

KeyDown event won't read current value - HELP!

Status
Not open for further replies.

iamareplicant

Programmer
Aug 7, 2004
50
US
Experts,

I need to use the keydown event in a text box to determine if the user has hit the enter key or the tab key.

If they have, I proceed to another routine to process the contents of that text box.

Problem: if I enter a value, say, "tr" into the textbox (key in "t", key in "r") then hit tab, I get to my keydown event's msgbox code (see below code), but in that event's routine, if I try to read the textbox's value, I get null (this is when i first open the form).

If I then type into the textbox, say, "CAT", then hit the tab key, the textbox's value is "tr" (see code below). In other words, the textbox's value is always the LAST value it had, not the current.

My simple test :

Code:
Private Sub txtQuantity_KeyDown(KeyCode As Integer, Shift As Integer)
            
    If KeyCode = 13 Or KeyCode = 9 Then
        MsgBox Me.txtQuantity
    End If


End Sub

with a form with just one text box and the keydown event.

Sure enough, if I enter a value in the textbox and hit tab, the textbox (see msgbox in code above)does NOT have as its value the current value I just typed.

What can I do programmtically to type a value into a textbox, hit tab, and then have the textbox's value be what I entered? How can I "refresh" the textbox after a tab keystroke so that the current value in the text box IS the current value in the text box?

What am i missing? My head is bruised from the continued banging into desk...(help please)

TIA,

JBG
 
How are ya iamareplicant . . .

The [blue]AfterUpdate[/blue] event hasn't occurred yet (comitted value), so you need the uncomitted value [blue]txtQuantity.text[/blue] . . .

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top