I have several subforms on a main form that are set to invisible. Depending on what button a user clicks, I want to make visible a single subform and set the others to invisible. I would like to just pass the subform name to a function that makes all subforms invisible and just the subform passed visible with a single line of code or very few lines (In short, avoid using a select case on a passed function parameter). I don't know how to pass the subform name and then what code should be used to set it to visible. I tried passing the subform as a form but got a message that the form couldn't be found. Everything I look at points to a subform on a main form being a control so my code looks like
[code/]
Private Sub FrmShow(cFORM As Control)
Me.NF_CTL.SetFocus
Me.SFADMIN_CATEGORY.Visible = False
Me.SFADMIN_CONTAINMENT.Visible = False
Me.SFADMIN_DEPT.Visible = False
Me.SFADMIN_DEPT_ACTIONS.Visible = False
Me.SFADMIN_OPER_DEPT.Visible = False
Me.SFADMIN_PAINTCODES.Visible = False
Me.SFADMIN_PASSWORDS.Visible = False
Me.SFADMIN_PERSONNEL.Visible = False
Me.SFADMIN_PRIORITY.Visible = False
Me.SFADMIN_DRWG_FMT.Visible = False
Me.SFADMIN_STATUS.Visible = False
cFORM.Visible = True
[/code]
But when I call the function using
FrmShow (SFADMIN_OPER_DEPT), I get a type mismatch error.
How can this best be accomplished?
Thanks in advance,
J9
[code/]
Private Sub FrmShow(cFORM As Control)
Me.NF_CTL.SetFocus
Me.SFADMIN_CATEGORY.Visible = False
Me.SFADMIN_CONTAINMENT.Visible = False
Me.SFADMIN_DEPT.Visible = False
Me.SFADMIN_DEPT_ACTIONS.Visible = False
Me.SFADMIN_OPER_DEPT.Visible = False
Me.SFADMIN_PAINTCODES.Visible = False
Me.SFADMIN_PASSWORDS.Visible = False
Me.SFADMIN_PERSONNEL.Visible = False
Me.SFADMIN_PRIORITY.Visible = False
Me.SFADMIN_DRWG_FMT.Visible = False
Me.SFADMIN_STATUS.Visible = False
cFORM.Visible = True
[/code]
But when I call the function using
FrmShow (SFADMIN_OPER_DEPT), I get a type mismatch error.
How can this best be accomplished?
Thanks in advance,
J9