I have a main form ("MF") with a big number of controls on it including one sub form. This sub form named "SF" and is related with two of the controls in the main form named "C1" and "C2".
When form is loaded SF is not visible.
When C1 or C2 got focus SF visibility set to True.
Now what I need is to set SF visibility to False if C1 or C2 lost focus, but the new focused control is not SF.
It seemed simple at the begining and it seemed straight forward, but it is not.
I used
Private Sub C1_GotFocus()
Me.SF.Visible = True
End Sub
Private Sub C2_GotFocus()
Me.SF.Visible = True
End Sub
Private Sub C1_LostFocus()
Me.SF.Visible = False
End Sub
Private Sub C2_LostFocus()
Me.SF.Visible = False
End Sub
This works great for all controls on the MF (Main Form).
The problem is that applies SF(Sun Form) too while I want to work on it.
SF is a list that I can pick a value from it and put it in the C1 or C2.
Now as SF disappears after C1 or C2 loses control, I cannot pick anything.
a workaround would be to omit the lost focus events for C1 and C2 and setting every other single control on the main form get focus control to hide SF.
While this works as I need. It seems not to be a good solution.
Is there a more straight forward way to accomplish this?
Remember Main form controls are too many too be coded this way.
Thanks.
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Most Valuable Expert award recognizes technology experts who passionately share their knowledge with the community, demonstrate the core values of this platform, and go the extra mile in all aspects of their contributions. This award is based off of nominations by EE users and experts. Multiple MVEs may be awarded each year.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.