Can certain tabs in a tab control show/hide based on a field in a form? (1 Viewer)

gojets1721

Registered User.
Local time
Today, 03:34
Joined
Jun 11, 2019
Messages
429
I've got this form full of complaints that shows each complaint entry one at a time. The form has a tab control and there's a bunch of tabs to store extra info. But a lot of the tabs are specific to certain types of complaints. So if its a billing compliant, there's a certain tab that has all these billing-specific fields. But if it isn't billing related, that tab is shown regardless and it's basically useless.

My question is, is there a way for tabs to show/hide based on what is listed in the category field? The category field is completely standardized and there's 4 categories

Thanks!
 

theDBguy

I’m here to help
Staff member
Local time
Today, 03:34
Joined
Oct 29, 2018
Messages
21,358
You can use something like:
Code:
Me.TabControlName.Pages(PageIndex).Visible=False
Hope that helps...
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 10:34
Joined
Jul 9, 2003
Messages
16,245
The example "Password Protected Tab" on the nifty Access website here may be useful to you:-

 

gojets1721

Registered User.
Local time
Today, 03:34
Joined
Jun 11, 2019
Messages
429
You can use something like:
Code:
Me.TabControlName.Pages(PageIndex).Visible=False
Hope that helps...
Hi DB...admittedly I'm not really sure where to place that code or how to input my info. The billing tab is just called 'Billing'. The category is also 'billing'.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 03:34
Joined
Oct 29, 2018
Messages
21,358
Hi DB...admittedly I'm not really sure where to place that code or how to input my info. The billing tab is just called 'Billing'. The category is also 'billing'.
Can you post a demo version of your db? We can't tell you where to put the code either if we have no idea what your form looks like.
 

gojets1721

Registered User.
Local time
Today, 03:34
Joined
Jun 11, 2019
Messages
429
Can you post a demo version of your db? We can't tell you where to put the code either if we have no idea what your form looks like.
Fair point. Sorry. See attached. Very raw example but hopefully it works. Each category tab has more category-specific data based on what type of complaint it is. If the entry is a billing complaint, I'd like for the other category tabs to disappear
 

Attachments

  • Example01.accdb
    736 KB · Views: 455

theDBguy

I’m here to help
Staff member
Local time
Today, 03:34
Joined
Oct 29, 2018
Messages
21,358
See if this does what you want. Open the form and cycle through the records.

PS. I only modified the Current event. You'll have to use other events based on what you really need.
 

Attachments

  • Example01.zip
    27.7 KB · Views: 415

MajP

You've got your good things, and you've got mine.
Local time
Today, 06:34
Joined
May 21, 2018
Messages
8,463
Code:
Private Sub ComplaintType_AfterUpdate()
  ShowTabs
End Sub

Private Sub Form_Current()
  ShowTabs
End Sub

Public Sub ShowTabs()
  Dim pg As Page
  'send focus to correct tab
  Me.ComplaintType.SetFocus
  For Each pg In Me.TabCtl22.Pages
     pg.Visible = (pg.Name = Nz(Me.ComplaintType))
  Next pg
End Sub
 

gojets1721

Registered User.
Local time
Today, 03:34
Joined
Jun 11, 2019
Messages
429
See if this does what you want. Open the form and cycle through the records.

PS. I only modified the Current event. You'll have to use other events based on what you really need.
Hi DB. This is exactly what I'm looking for. Do you mind briefly explaining how you got this to work? That way I can replicate it in my actual DB
 

theDBguy

I’m here to help
Staff member
Local time
Today, 03:34
Joined
Oct 29, 2018
Messages
21,358
Hi DB. This is exactly what I'm looking for. Do you mind briefly explaining how you got this to work? That way I can replicate it in my actual DB
Hi. It's basically the same logic as what @MajP posted, except I assumed you always wanted the Overview tab displayed for all categories. If you go through the code, let us know if you don't understand any of them.
 
Last edited:

gojets1721

Registered User.
Local time
Today, 03:34
Joined
Jun 11, 2019
Messages
429
Let's say in my actual database, I want the first two tabs to always remain. Would the alteration in the code be:

Code:
For x = 2 To Me.TabCtl22.Pages.Count - 2
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 06:34
Joined
May 21, 2018
Messages
8,463
Using @theDBguy assumption about the Overview
Code:
Public Sub ShowTabs()
  Dim pg As Page
  'send focus away from tab
  Me.ComplaintType.SetFocus
  For Each pg In Me.TabCtl22.Pages
     pg.Visible = (pg.Name = Nz(Me.ComplaintType) Or pg.Name = "Overview" or pg.name = "Some Other Name")
  Next pg
End Sub

You can add ORs to the check
 

theDBguy

I’m here to help
Staff member
Local time
Today, 03:34
Joined
Oct 29, 2018
Messages
21,358
Let's say in my actual database, I want the first two tabs to always remain. Would the alteration in the code be:

Code:
For x = 2 To Me.TabCtl22.Pages.Count - 2
No, it would be more like:
Code:
For x = 2 To Me.TabCtl22.Pages.Count - 1
 

Users who are viewing this thread

Top Bottom