Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hide Tabs in a Form Based on a field.

Status
Not open for further replies.

snoopy92211

Technical User
Jun 29, 2004
67
US
I would like to hide a tab based on a combo box.

my filter is based on a field, fruit.

if i filter my records on apples , I want the tabs apple1 and apple2 to be visible (and orange inivisible).
if i filter based on oranges, I want the tabs orange to be visible and (apple1 and apple2 invisible).


Does this make sense?

Thanks!

Angel
 
yes it is possible, are you using a combo box or general text box???

what is the name of your tab control, and the pages within it, and the name of your control (filter box) source.

and i will write the code for you...
 
How are ya snoopy92211 . . . . .

Not the best Idea for code to be dependent on [blue]Caption Text[/blue]. So to alleviate this and [blue]leave you free to change captions[/blue] at any time, do the folowing:

For each Tab, [purple]enter some text for detection of the Tab[/purple] in the [blue]Tag Property[/blue]. Those tabs which will be controlled in common receive the same text of course. For instance; in the Tag Property for Apple1 & Apple2 enter [purple]App[/purple]. [blue]It is this text the code will be looking for[/blue] (in reference to your combobox) [blue]to determine what tabs to show/hide.[/blue]

Next . . . in the [blue]After Update[/blue] event of the combobox, copy/paste the following code ([blue]you[/blue] substitute proper all in [purple]purple[/purple]):
Code:
[blue]   Dim pg As Page, cmpTxt As String
   
   If Me![purple][b]ComboboxName[/b][/purple] = "Apples" Then
      cmpTxt = "[purple][b]App[/b][/purple]"
   ElseIf Me![purple][b]ComboboxName[/b][/purple] = "Oranges" Then
         cmpTxt = "[purple][b]Org[/b][/purple]"
   End If

   If cmpTxt <> "" Then
      For Each pg In Me![purple][b]TabControName[/b][/purple].Pages
         If pg.Tag = cmpTxt Then
            pg.Visible = True
         Else
            pg.Visible = False
         End If
      Next
   End If[/blue]
Thats it . . . . give it a whirl and let me know . . . .

Calvin.gif
See Ya! . . . . . .
 
Well...here's the issue.

It seems to work, but I only want to hide certain pages in the tab control, not the entire control.

The fruittype combobox has 3 choices - apples, oranges, bananas.

the tab control, named tabFRUIT has 4 pages:
duedates, apples1, apples2, and oranges1

If I choose Apples (the combobox is fruittype),

I want to automatically show duedates, but I also want to show apples1 and apples2

If I choose bananas, I want the duedates page to show.

If I choose oranges, I want to show duedates and oranges1.

Make sense?

Thanks!!




 
OK snoopy92211 . . . .

Set the Tag Property for each tab as follows:
[blue]duedates Tab to [purple]Due[/purple]
apples1 Tab to [purple]App[/purple]
apples2 Tab to [purple]App[/purple]
oranges Tab to [purple]Org[/purple]
[/blue]
Save the form.

Then replace the code with the following (the code assumes the combobox has one column):
Code:
[blue]   Dim pg As Page, cmpTxt As String
   
   If Me!FruitType = "Apples" Then
      cmpTxt = "App"
   ElseIf Me!FruitType = "Oranges" Then
         cmpTxt = "Org"
   Else
      cmpTxt = "Ban"
   End If

   If cmpTxt <> "" Then
      For Each pg In Me!tabFRUIT.Pages
         If pg.Tag <> "Due" Then
            If pg.Tag = cmpTxt Then
               pg.Visible = True
            Else
               pg.Visible = False
            End If
         End If
      Next
   End If[/blue]
Give it a whirl & let me know . . . .

Calvin.gif
See Ya! . . . . . .
 
Forgive my ignorance, but where exactly do I set tag properties? (there is one tab, but 4 pages in the tab)


You rock by the way! :)
 
snoopy92211 . . . . .

I'm saying [blue]Tabs[/blue] instead of [blue]pages[/blue].

If the properties window is not already open, double-click the [blue]black square[/blue] just to the left of the ruler. Select the [blue]Other Tab[/blue]. Now just select each page & you'll see the [blue]Tag Property[/blue] right there.

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top