I have a bit(alot) of error catching when a user moves from one textbox to the next in both gotfocus and lostfocus. However I don't want the error messages popping up when they go to quit because the field they are/were in is blank. Normally I would want the error trapping but it's just irrating for it to popup when it shouldn't be... I think I'll just move all the trapping to the gotfocus of the previous textbox. It would be easier and more logical.
HI Twigs,
It is advisable to create your method for catching up data entry errors. Example.. Add a method called "CheckData" in your form. IN this method, do all the validation and set the focus to the appropriate text box or check box or edit box whatever, if the data is invalid and while doing so display the error message in a wait window or in a message box before setting the focus. Return .t. in the above method, if everything is ok.
SO in the saving method, add the code..
IF THISFORM.CheckData()
... update data files..
ENDIF
This will be more convenient than checking in lost focus event of each control. Again, the lost focus can contain code to set the inter dependent control values, if needed.
Since the lost focus is not always fired (what if the user never touched the control only.. since you can click on control1 and then proceed to click on control3), it is advisable to follow the above suggested method.
If needed, in your base data entry form, you can add a method "CHeckData" and in that just put the code RETURN .T.
Then in other subclassed forms, you need to only add the relevant code. The advantage is that, in your buttons class.. save button, you can add the code,
IF ThisForm.CheckData()
TABLEUPDATE()
ENDIF
SO subclassing will be easier.
HOpe the idea helps you ramani
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
If you want to identify which control has the focus, just look to "Thisform.ActiveControl". This is an object reference to the control that has the focus.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.