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

Valid event fires when clicked outside of test box

ravicoder

Programmer
Apr 29, 2006
34
IN
Hi all

I have a data entry form with some text fields and <save> and <cancel> buttons. My issue is that when focus is on a text box and cancel button is clicked the valid event of the text box fires and user has to click on ok on the messagebox that appears and then again click on cancel button

sample code

rkey = Readk()

If _rkey()
If Not Empty(This.Value)
helpselected = .F.
helpcode = ''
helpname = ''
=namehelp("Centres Master",'master_centres','centre_code','centre_name',Allt(This.Value))
If helpselected
This.Value = helpname
Thisform.centre_code = helpcode
thisform.getstate()
thisform.Refresh()
Endif
Else
Thisform.centre_code = ''
Endif
Endif
end of sample code

is there any way I can avoid this?

thanks in advance
 
I don't quite understand your sample code but I am assuming you are trying to validate the entry in this textbox and show the message if there is no value. Do it on LostFocus() and return -1 so the cursor stays in the textbox. I don't really like this because the user will have to enter something, otherwise they will not be able to leave the textbox. You can do validation on command button OK or SAVE instead of on VALID(), this way, if the user enters CANCEL, it doesn't matter what in the texbox
 
Right now i have no access to my development-environment. But check if the MOUSEDOWN-Event in your CANCEL-Button fires earlier as the VALID-Event.
 
See Hacker's Guide last paragraph of using LASTKEY() in the valid event code. That's a standard that should be known by all foxpro developers.
 

Part and Inventory Search

Sponsor

Back
Top