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

Set focus back to invalid textbox entry

Status
Not open for further replies.

VBFOXDEV35

Programmer
Mar 26, 2001
77
US
Hello again all. Now I have this twist to the VFP world.

I have a textbox where I want to make sure only Numeric values are entered into the textbox, if not I want the focus to go back to that textbox (currently using the lostfocus()), select all the current textbox value (this.format = "K") and then re-type the numeric expression.

Everytime the LostFocus Event fires, The focus goes to the next textbox, here is what I have right now.

GotFocus Event of Textbox
This.Alignment = 0
This.Format = "K"

LostFocus Event of Textbox

LOCAL dblValue
dblValue = This.Value
IF TYPE(dblValue) = "N" then
This.Value = NUMFMT(ALLTRIM(this.Value), 15, 2, "")
This.Alignment = 1
ELSE
MESSAGEBOX("Numeric expression only, please re-enter numeric value.",64, "Notice")
This.SetFocus
ENDIF

Any suggestions would be greatly appreciated. Thanks

Art
Art DeGaetano II
Software Developer, MOUS
 
HI

LostFocus Event of Textbox

LOCAL dblValue
dblValue = This.Value
IF TYPE(dblValue) = "N" then
This.Value = NUMFMT(ALLTRIM(this.Value), 15, 2, "")
This.Alignment = 1
ELSE
MESSAGEBOX("Numeric expression only, please re-enter numeric value.",64, "Notice")
[COLOR=/blue]
NODEFAULT
[COLOR=/]
ENDIF
ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Can you not just use the "99999" clause then validate it so they can not leave with out some kind of entry that you allow.
 
RAMANI, THANK YOU!!!! This was killing me for the past 30 minutes. Thanks all for the reply's, duh it was the old NODEFAULT. Leave it to Uncle Bill not to have this in the help file for the lost focus.

Art
Art DeGaetano II
Software Developer, MOUS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top