PRMiller2
Technical User
- Jul 30, 2010
- 123
I have a form called fmnuMain that contains a tab control with a number of pages. I have a table populated with Form names and whether or not they are accessible based on that user's security level. On startup, I loop through that table, obtain the number of forms for which the user has access, and then show or hide the appropriate number of page tabs. I then loop through those page tabs and set the Tag text to contain the subform name I want loaded when a page tab is clicked.
When the user clicks a page tab, the subform control ("sfmMenu") on that page loads the form named on the Tag text of that page.
I have one tab called Admin, where the sourceobject of the sfmMenu control will load sfmAdministration. In an effort to reduce the number of tabs, I have a listbox control that allows users to select various admin options. One of those options opens sfmStaff (in control sfmAdminComponent), which itself resides in sfmAdministration (in control sfmMain). When the user clicks the option in the listbox that loads this form, I hide the listbox, change sfmAdminComponent to visible, and sfmAdminComponent.SourceObject to equal sfmStaff.
No problems there.
I added a close button to sfmStaff. When clicked, I want the sfmStaff to disappear and then sfmAdministration tab to reappear, complete with the list boxes. I have really been struggling with syntax here. When attempting to hide the subform, I receive the error message, "You can't hide a control that has the focus." I receive this message even though I move the focus to a control on my main form. Here's what I've got:
Any recommendations?
When the user clicks a page tab, the subform control ("sfmMenu") on that page loads the form named on the Tag text of that page.
I have one tab called Admin, where the sourceobject of the sfmMenu control will load sfmAdministration. In an effort to reduce the number of tabs, I have a listbox control that allows users to select various admin options. One of those options opens sfmStaff (in control sfmAdminComponent), which itself resides in sfmAdministration (in control sfmMain). When the user clicks the option in the listbox that loads this form, I hide the listbox, change sfmAdminComponent to visible, and sfmAdminComponent.SourceObject to equal sfmStaff.
No problems there.
I added a close button to sfmStaff. When clicked, I want the sfmStaff to disappear and then sfmAdministration tab to reappear, complete with the list boxes. I have really been struggling with syntax here. When attempting to hide the subform, I receive the error message, "You can't hide a control that has the focus." I receive this message even though I move the focus to a control on my main form. Here's what I've got:
Code:
Private Sub cmdClose_Click()
On Error GoTo Err_Handler
Forms("fmnuMain").SetFocus
Forms!fmnuMain.SetFocus
Forms("fmnuMain")("txtFocus").SetFocus
Forms!fmnuMain.sfmMenu.Form!sfmAdminComponent.Visible = False
Forms!fmnuMain.sfmMenu.Form!sfmAdminComponent.SourceObject = ""
Forms!sfmAdministration.lstCategory.Visible = True
Forms!sfmAdministration.lstItem.Visible = True
Exit_Handler:
Exit Sub
Err_Handler:
Call LogError(Err.Number, Err.Description, "sfmStaff.cmdClose_Click()", , True)
Resume Exit_Handler
End Sub
Any recommendations?