Full Version: When does lost focus event actually loose focus?
UtterAccess Forums > Microsoft® Access > Access Forms
JackSawyer
I am trying to verify that 3 controls ( out of a few dozen) do not have the focus by using the Lost focus event on one of them ( so when button2 looses focus, it checks that the new focus is not now on btn1 or textbox1). its not working. I think the problem is that even though the lost focus event has triggered, it hasnt truely lost focus and the next control hasnt actually recieved the focus yet. is that accurate?
freakazeud
Hi,
yes...the lost focus event will fire when the focus is leaving the control but it will not have shifted to a different control yet so you can't use that event to check if some other control has received the focus because it is still with that control.
HTH
Good luck
JackSawyer
ahh. too bad. Is there a way to check where the focus is going at that point?
freakazeud
Mhh...not really...you could use code on each form control's on got focus event to pass the name of the control to a variable and use that but that might be a lot of work e.g.:
ourVariable = Screen.ActiveControl.Name
HTH
Good luck
JackSawyer
I think the variable idea would be quite a bit of work as you said.
oh well, I'll have to figure out something else.
Thanks for the help
balaji
Why don't you explicitly control where the focus is going instead of trying to guess where it might go? You can set focus to any other control on that form in the lostfocus() event of this control.
JackSawyer
I cant. What I'm trying to do is this. I have a form with 3 columns. 1st is textboxes for a qty, 2nd and 3rd are buttons for + and - there are 20 rows this way- next to these rows I have a continuous subform with basicaly inventory info including a qty column. I use the +/- buttons to raise /lower the value in the textbox and/or just type in a value. the question above is for when I leave that 'row' ( the textbox, or either button) I then want to add that textbox value to the row next to it in the subform .
o.. I never know where the 'new focus' is going to go. Where ever the user decides weather its to update values for another row, scroll the subform, make other choices on the form ( theres more than described above) or close the form
Any suggestions?
balaji
Why not use the afterupdate() or onclidk() events of these controls to do your calculations instead of relying on the lost focus event?
JackSawyer
I dont see how that would work. I use the +/- to change the textbox value (using the onclick event)- if I click it 10 times it goes up ( or down) 10 or the amount to change by is entering directly - I dont want to add the new value (textbox) to the existing ( in the subform) until the textbox is at the desired value, the desired value would be triggered by leaving that row - again, a row consisting of a textbox and 2 buttons times 20 rows.
eaving that row is where I'm having the problem - how do I determine I've left that row if I cant use lostfocus?
balaji
Maybe you can use the oncurrent() event of the form. That is triggered only when you change records I think.
JackSawyer
I dont think I can go that way either.. the form is unbound, so no records..
appreciate your suggestions...
JackSawyer
Hey, your suggestion gave me an idea that may work.
I'm going to make a single subform with 1 textbox and the 2 buttons. then put 20 of those subforms on the mainform representing the rows. When the subform is exited it would be the same as changing rows, so then I can then do my other calculations..
hope this works!! Thanks
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.