Not sure about the 127 key, I think I got this code elsewhere and that was already in it... I commented it out and I still have the same problem.
In my case the textbox is in a column of a grid. I am also using a buffered table as the record source, with the underlying table not yet updated, as I want to check whether the user *really* wants a new record (if the textbox is blank, I TABLEREVERT() on LOSTFOCUS)
In fact, the behaviour seems to change if I commit changes to the table before I enter the offending textbox.
>I is not happening to me. Justr create a simple form with text box & command button. Paste Your code in Keypress event of the TextBox & change Filename & Order To point to one of my files. Everything is OK: no Change of Focus during keypres. BTW what is the 127 key?
>
>>Heh, I wish... It happens as soon as I press a key, there is no maximum # of characters. Thanks for the thought.
>>
>>>A wild stab from Fox2.6 perspective.............
>>>
>>>Is it possible that SET CONFIRM = OFF and you have reached the maximum number of input characters?
>>>
>>>
>>>>Hi,
>>>>
>>>>I hope somebody else can see why I am unexpectedly losing focus on the textbox which has the following code in its KEYPRESS method:
>>>>
>>>>
>>>>
>>>>LPARAMETERS nKeyCode, nShiftAltCtrl
>>>>lcAlias = 'inventory'
>>>>lcField = 'upname'
>>>>
>>>>if nKeycode = 127
>>>> if empty(this.value)
>>>> nodefault
>>>> endif
>>>>endif
>>>>
>>>>
>>>>IF empty(this.Text)
>>>> keyval=Seek(UPPER(Chr(nKeyCode)),lcAlias,lcField)
>>>>else
>>>> keyval=Seek(UPPER(subs(This.Text,1,This.SelStart)+Chr(nKeyCode)),lcAlias,lcField)
>>>>ENDIF
>>>>_name = inventory.name
>>>>
>>>>
>>>>
>>>>If keyval
>>>> nCurPos = This.SelStart + 1
>>>> This.Value = _name
>>>> This.SelStart = nCurPos
>>>> If Len(Allt(_name)) - nCurPos > 0
>>>> This.SelLength = Len(Allt(_name)) - nCurPos
>>>> ENDIF
>>>>
>>>> Nodefault
>>>>
>>>>ENDIF
>>>>
>>>>
>>>>
>>>>The bizarre thing is that it works as I expect it to for a few times, then on the third or fourth invocation I will suddenly have the LOSTFOCUS method fire, although I am only pressing the normal alphanumeric fields.
>>>>
>>>>Any ideas?
On a CLEAR day you can see forever.