Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Boudewijn Lutgerink
  Where is Boudewijn Lutgerink?
 Hoonaardstraat, Driel
 Boudewijn Lutgerink
 To: Jagdish Sharma
  Where is Jagdish Sharma?
 Jagdish Sharma
Subject: RE: Valid Event Ignore
Thread ID: 112793 Message ID: 112800 # Views: 48 # Ratings: 1
Version: Visual FoxPro 9 Category: General VFP Topics
Date: Monday, November 13, 2006 9:27:34 AM         

> Dear Experts
> I write the following codes in text box valid event & Cancel button's click event
> Mytext.Valid Event
> IF this.value < ksfdate OR this.value > ksldate
> =MESSAGEBOX("Date Range is "+dtoc(ksfdate)+" To "+dtoc(ksldate),32)
> endif
> if empty(this.value)
> =MESSAGEBOX("Date cann't be left Blank",0,"Warning")
> retu 0
> endif
> mycommandgroup.revert.click event
> SELECT stock
> SELECT itmaster
> SELECT procdtl
> SELECT prochead
> SELECT prochead
> STORE .F. TO addrec,editrec
> thisform.curseqno = 0
> thisform.cmdenbldsbl
> THISFORM.COmmandgroup1.ADD.SetFocus
> I want to ignore the valid event of text box when user click on revert button please help me.
> thanks in advance
> With warm regards
> Jagdish

As you write it yourself the valid is an EVENT. Events are fired always as they occur. That is the whole idea behind an event as opposed to methods that have to be called either by an event OR by other methods.
By clicking the cancel button you actually leave the textbox and that fires automatically the valid event (amongst others).
The rule I follow for that is WHEN you have GOTFOCUS you also have a VALID LOSTFOCUS. (Meaning that WHEN one control GOT FOCUS, another control has a LOSTFOCUS, but before that the VALID is fired first.)

I'ld say that you better place the code from your valid event to the safe method that, no doubt, is also somewhere on your form.
Then, if the wrong value (or no value) is put in the textbox you can redirect the user back to the textbox (setfocus() ) and make him/her fill in the correct value.

If the correct value IS filled in you can simply store the data to the table where it belongs


Boudewijn LutgeĀ®ink
The attitude of "An eye for an eye and a tooth for a tooth" will make this world toothless and blind (Ghandi)


Valid Event Ignore Posted by Jagdish Sharma @ 11/13/2006 8:40:37 AM
RE: Valid Event Ignore Posted by Boudewijn Lutgerink @ 11/13/2006 9:27:34 AM
RE: Valid Event Ignore Posted by Ken Murphy @ 11/13/2006 12:20:50 PM
RE: Valid Event Ignore Posted by Pete Sass @ 11/13/2006 5:47:33 PM
RE: Valid Event Ignore Posted by Craig Williams @ 11/14/2006 4:45:19 AM
RE: Valid Event Ignore Posted by Boudewijn Lutgerink @ 11/14/2006 5:23:24 AM