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

Validation By-Pass

Status
Not open for further replies.

RWF

Programmer
Apr 16, 2001
24
US
The Search is down, and I did check the FAQ.

The Valid method appears to be somewhat of a trap to get out of.

It is readily obvious that each validation could be adjusted, or the valid code could be placed in the LostFocus method, but I would prefer a more elegant solution.

I would like to be able to globally(or by form) by-pass the Valid event for any/all given controls.

ON KEY LABEL does not work, as it is outside the container, which precludes using something like "ON KEY LABEL Escape ThisForm.Object.SetFocus"(I have tried it).

I think something that would redirect the ON KEY LABEL command back into a form container, such as "DO code in Form", but I am not sure even that would work, even if I knew how to do it.

Any ideas are welcome.
 
create a property to hold the value of the object (ie:baddata)
create an event to activate and fill thisform.baddata with the value of the object in question, then replace the value of the object in question with blank or ? to satisfy the valid issue, in lostfocus replace the value with thisform.baddata

Only a suggestion, but one has to wonder why you would want to do this in the first place.
 
You can have a common MyValidation() procedure at the form level.
MyValidation() can contain.. each of the fields validation codes...
** TextBox1 validation
IF txtBox1.Value == ! (my rules etc etc)
display message "My TextBox Value1 is not valid 'coz..
ThisFor.txtBox1.SetFocus
ENDIF
** TextBox3 validation ..
...
etc.

This MyValidation() can be called in the save method() of the form.

Beware of Grids.... The valid event of a Grid.ColumnX.Text1.Valid() will not fire even if there is a change in value .. but the form is closed my pushing the close button. But the value gets stored if the routined dont take care. In such cases, the validation rules catch, if planted properly.
ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
 
Thanks to both of you, and almost, but not quite.

The reason for this request is to allow a user to <Esc> out of any field containing a validation. As far as I know, NO other event, with the exception of ON KEY, can occur before the validation event.

Remember I am in the control and the next event to fire is the Valid.

The first answer requires modifying each object, which I am trying to avoid. The second cannot(I believe) occur because the object validation event must be processed prior to the MyValidate().

Maybe I should rephrase.

Is there any way to call a method within a form/class via an ON KEY event and execute code within that form/class and have the object in question be recognized as part of the container. Keep in mind that the ON KEY event exists outside the form container.
 
I think I am not very clear of the requirement...
May be the Programatic Change Event.. or the Interactive event of the Form... could help you... They are to some extent like on key label event ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
 
RWF

The first answer requires modifying each object, which I am trying to avoid.

If all or some of the controls have validation routines in their .Valid events, then it's unlikely you will find a workaround without modifying the code in the .Valid events.

Assuming you subclassed all your controls, you could add:-

IF nKeyCode = 27 && Esc key pressed
[tab]THIS.Valid()
ENDI

to the .KeyPress() event.

If the .Valid() event, put:-

IF LASTKEY() = 27
[tab]KEYBOARD [{TAB}]
ELSE
[tab]* Validation code
ENDIF

Alternatively add:-

IF nKeyCode = 27 && Esc key pressed
[tab]THISFORM.MyValidation()
ENDI

to the .KeyPress() event.

In the THISFORM.MyValidation() event, put:-

IF LASTKEY() = 27
[tab]KEYBOARD [{TAB}]
ELSE
[tab]* Validation code
ENDIF

Hope this helps.

Chris :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top