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!

Detect the last object activated

Status
Not open for further replies.

cslawtom

MIS
Sep 3, 2001
161
HK
Hi All,

For example, a form with one text box and one combo box and two command buttons.

In the lostfocus of the text box, it will activate (pull down) the combo box automatically and allow user select from the list. But in fact, the combo box should not be activated if command button A clicked.
So in this case, how could I detect the command button A clicked in the lostfocus of the text box.

Many thanks.
 
HI

DOnt put the code in the lost focus of the test box to bring down the combo box list. That is not a correct way. I suggest to be as independent as possible in their functionalities.

So the suggestion is to put the code in the Got Focus event of the Combo box to pull it down. So shift the relevent code in the Lost focus of Text box to the GotFocus of ComboBox.

This will solve your problem. :) ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Hi Ramani,

The reason of putting the code inside the lostfocus is as below. May be you could give some advice to me in this situation.

The text box is for the customer code and the combo box is a list of customer code which is disabled.

If customer code inputted in the text box is correct, it moves to next control (not the combo box). Otherwise, in the lostfocus, it will enable the combo box and setfocus to it and activate keyboard "{F4}" to pull down the combo list.

Therefore I would like to bypass the above action when a cancel button click. Otherwise it always activate the combo box.

I think that it could be another possible way to do so. I am trying the other method but of course, would like to have your advice.

Many thanks.
 
HI

CustTxtBox.LostFocus
********************
IF SEEK(This.Value) IN myTable
** Code is Valid
ThisForm.myWantedControl.SetFocus()
ELSE
ThisForm.myCombo.SetFocus()
ENDIF

myCombo.GotFocus
****************
** Locate the record to the nearest account
KEYBOARD "{F4}"

*******************************************
:) ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Hi Ramani,

Will check the code and reply later. Thanks.
 
Hi Ramani,

Your code is same as mine. But I would like to do the following.

I don't want to activate the combo box when invalid customer code entered.

Both our codes, if invalid customer code entered, it will activate the combo box.
 
Hi Ramani,

I just found that I could place THIS.SETFOCUS() in CLICK event of the COMMAND BUTTON. Thanks anyway.

But if anyone has better idea, please let me know. Thanks.
 
I think this.setfocus() would still have to execute the lostfocus event where ever prior focus was.
In your situation, I set a variable .t. in command.click event and first lines in the textbox lostfocus I do
if variable .t.
veriable = .f.
return
endif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top