Link to home
Start Free TrialLog in
Avatar of Joy Gomez
Joy Gomez

asked on

Subform visibility


I have a main form (Main_Menu) and 2 sub forms (Main_DLMP and Main_DeptView). In the main menu I have 2 labels that act as menu.  I have click events on both these labels.  I want to make one visible, and the other not visible.  But I struggling with this.  These are the 2 events I have for each of the labels in my main form.

 This is the event on the first label. As default Main_DLMP visibility is set to True and DLMP_DeptView is set to False.
    Forms![Main_Menu]![Main_DLMP].Form.Visible = True
    Forms![Main_Menu]![Main_DeptView].Form.Visible = False

This is the event on the second lablel
    Forms![Main_Menu]![Main_DeptView].Form.Visible = True
    Forms![Main_Menu]![Main_DLMP].Form.Visible = False
I am getting an error on the second label... Cannot set focus.
Avatar of Anders Ebro (Microsoft MVP)
Anders Ebro (Microsoft MVP)
Flag of Denmark image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Normally Labels don't need Focus...
What you probably need is that the Labels are unassociated with any controls. To check it just right clicks -->Properties..check if Events are displayed...if its blank ..then the easy way is to make a copy of the Label delete the old Label..rename the New label to match the old name and you should be fine
Also for Visiility
Me.Lbl1.Visible = Not Me.Lbl2.Visible

Open in new window

Probably i confused Labels with Subforms..
Ok np
On the click event of Labels...
Form_NameOfSubForm1.Visible = Not Form_NameOfSubForm2.Visible

Open in new window

Avatar of Joy Gomez
Joy Gomez


Thank you Anders... worked great!

John... thanks for your continuous support.