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

Check for Focus

Status
Not open for further replies.

twigs1981

IS-IT--Management
May 29, 2002
52
US
I would like to check certain textboxs to see if they have the focus, is there a way to test that?

Thanks much
 
What are you trying to do?

I'd create a public variable that changes when a box gets/looses focus.

Brian
 
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.

Ian
 
Thanks guys :-D I really appricate the help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top