Hide tab macro

nick5196

Registered User.
Local time
Today, 12:09
Joined
Feb 17, 2011
Messages
43
Hi, I'm (trying to) create an access database containing a form with multiple tabs. My objective is to make a button with a module that will hide (make not visible or disable) one of the tabs if a combobox has a specific value. Essentially, I want to hide the tab 'qA' if the combobox has a value of 'AA'. The problem appears to be referring to the correct tab within the form. I've been trying to do this for a couple of hours and have been through many error messages, so any help would be greatly appreciated.

I've attached a copy of the database to help prevent confusion.

Thanks allot, I really appreciate it,
Nick
 

Attachments

Don't have 2007 on this machine, but the code would look like:

Code:
  If Me.ComboName = "AA" Then
    Me.PageName.Visible = False
  Else
    Me.PageName.Visible = True
  End If

Where PageName is the name of the tab (name, not caption).
 
I tried this but experienced an error message; "invalid use of the word "Me"". I have experienced this before, possibly it is to do with how I am defining the tab? I found these methods of referring to a single tab but am unsure which to use and how to implement them.

Thanks allot for trying
 
If it's just the me it doesn't like...

Code:
  If Forms!FormName!ComboName = "AA" Then
    Forms!FormName!PageName.Visible = False
  Else
    Forms!FormName!PageName.Visible = True
  End If

:edit:

If the tab control is in a subform and the combo box in the main form then slightly different code is needed:

Code:
  If Forms!FormName!ComboName = "AA" Then
    Forms!FormName!SubFormControlName.form!PageName.Visible = False
  Else
    Forms!FormName!SubFormControlName.form!PageName.Visible = True
  End If
 
Where exactly do you have the code?
 
Just tried this method and received an error which read "this visual basic module contains a syntax error".
Heres a copy and paste of what I have written:
If Forms!add_details!course = "AA" Then
Forms!add_details!qa.Visible = False
Else
Forms!add_details!qa.Visible = True
End If
Not sure where the errors are.

Thanks allot for your help.
 
It needs to go in the combo's AFTER UPDATE event and this works (I just tested):
Code:
Private Sub course_AfterUpdate()
    If Me.course = "AA" Then
        Me.qAA.Visible = False
    Else
        Me.qAA.Visible = True
    End If
End Sub

If the code isn't firing for you need to do this.
 
Pbaldy:
I am creating the code as a module and the creating a macro to run the code.
I am then assigning it to the "course" combo box.
 
Pbaldy:
I am creating the code as a module and the creating a macro to run the code.
I am then assigning it to the "course" combo box.
Too much - just put it in the combo's After Update event. No need for the other module and no need for the macro.
 
In a standard module you would need the full form reference.
 

Users who are viewing this thread

Back
Top Bottom