Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I signed up to your site to get help with a problem and I am so glad I did. I found the help I needed immediately. Thanks to all who contribute to your site..."

Geography

Where in the world do Tek-Tips members come from?
PRMiller2 (TechnicalUser)
21 Jun 12 14:32
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:

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?
kjv1611 (TechnicalUser)
29 Jun 12 11:44
I think you're not referencing the subform correctly. I forget the exact syntax off-hand, and I usually just search it online to find it... but it's something like this..

Forms!MyMainForm!MySubform!Form.Visible = false

Well, that's my initial stab at what you want, but give it a try, and if that isn't correct, do some searching on referencing subform conrols from form, and you should find what you need.

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57

PRMiller2 (TechnicalUser)
29 Jun 12 12:15
Hey kjv, thanks for the reply. There's a great reference here: http://access.mvps.org/access/forms/frm0031.htm. I was unsuccessful with all of the different combinations I tried, so I ended up just splitting the subform's subform out to a modal pop-up.
kjv1611 (TechnicalUser)
29 Jun 12 14:41
Yeah, I'm sure that makes for MUCH easier referencing. thumbsup2

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close