Form Refresh triggering LostFocus on a subform

lespritdelescalier

Registered User.
Local time
Today, 03:28
Joined
Mar 16, 2015
Messages
50
Hey all,

I'm kind of stumped with this one. I have a parent form which is being refreshed from another module using the following:

Code:
frmParent.Refresh

Immediately after the line of code above, the code jumps to a LostFocus event on a child form belonging to frmParent. frmChild is in datasheet view, if that makes any difference.

Is there a reason why it's executing this code? It's not trying to execute any other LostFocus events on the child form.

Thanks!
 
My guess is if you are refreshing the parent, the focus has moved from the child/subform.
You could try inserting a Me.somecontrol.setFocus to see if you can do the refresh and put the focus where you want/need it.

Totally untested.
Good luck.
 
A .Refresh includes rewriting the record currently open in the form so (if changes were pending) might count as an update. Is there some type of update-related event that might have a .SetFocus effect? (Like an .AfterUpdate or .BeforeUpdate.)
 
I tend to agree with jdraw's guess. In answer to your question:

Is there a reason why it's executing this code? It's not trying to execute any other LostFocus events on the child form.

It'll only execute the LostFocus event on the Control, on the Subform, that currently has Focus, when the Refresh is executed. I assume the LostFocus event that is firing is doing something that is inappropriate...if so, a workaround would be to move Focus to some Control, on the Subform, that doesn't do anything when its LostFocus event fires, then do the Refresh.

Linq ;0)>
 
a workaround would be to move Focus to some Control, on the Subform, that doesn't do anything when its LostFocus event fires, then do the Refresh.

This is what I tried after reading jdraw's comment, but it still didn't change anything. Thanks, though!
 
What LostFocus event event is firing? Is it the LostFocus event of the Subform Control itself?

What does the event do?

Linq ;0)>
 
The subform is on an order entry form, and it's used to enter the order lines. The specific field that has the LostFocus event that's firing is for item discount percentages, and it recalculates the line value and updates the total field on the line (if the discount is greater than zero).
 
It's not trying to execute any other LostFocus events on the child form.

Just for clarity, it can't trigger more than one .LostFocus event because there is only one focus to lose. BUT ... it occurs to me that you could have stated this a little awkwardly due to your (understandable) confusion.

Are you saying that if you had focus on something else, your .Refresh DOESN'T trigger a .LostFocus?
 
Can you post a copy of the database -remove anything confidential -change names to PorkyPig, Daffy Duck..?. And give instructions to get to the issue involved.

Might be the quickest way to some focused response.
 

Users who are viewing this thread

Back
Top Bottom