Hiding/UnHiding Tab Controls based on Combo Box Selection (1 Viewer)

Smokeeater

Registered User.
Local time
Today, 11:45
Joined
Jan 15, 2009
Messages
58
I have frmIncident that has a 2-column combo box (cmbIncidentType). Column (0) is IncidentType, Column (1) is YES/NO. This combo box feeds from a Query and currently has about 15 "types" of which 4 have a "Yes" tied to them, then rest "No".

There are situated on a TabControl (tabIncident) with 5 sheet tabs. If the Incident Type selected in the Combo Box has a corresponding "Yes" in Column (1) then all 5 sheet tabs need to be visible. If it is "No", then only three of the five are visible. Here it he current code I am using for the AfterUpdate event on the combo box:

Private Sub cmbIncidentType1_AfterUpdate()

If Me.cmbIncidentType1.Column(1) = "Yes" Then
pgEmerIncidentRpt.visible = True
pgNarrClose.visible = True

Else

pgEmerIncidentRpt.visible = False
pgNarrClose.visible = False

End If

End Sub

Here are the events tied to the form frmIncident in the AfterUpdate(), Form_Current(), and Form_Open events.


If cmbIncidentType1.Column(1) = "Yes" Then
pgEmerIncidentRpt.visible = True
pgNarrClose = True

Else

pgEmerIncidentRpt.visible = False
pgNarrClose.visible = False

End If

End Sub


When I open the form is will set the proper sheet tabs that need to be visible, however once I cycle to the next record, or select a different IncidentType, even one with a "YES' in column (1), it will only show the (3) sheet tabs. I can never get it to show all 5.

In the code, the only (2) sheet tabs that need to visible = true or visible = false are shown, starting with "pg".

Thanks so much!
 

missinglinq

AWF VIP
Local time
Today, 11:45
Joined
Jun 20, 2003
Messages
6,423
Isn't this

Code:
If cmbIncidentType1.Column(1) = "Yes" Then
  pgEmerIncidentRpt.visible = True
  pgNarrClose = True
supposed to be

Code:
If cmbIncidentType1.Column(1) = "Yes" Then
  pgEmerIncidentRpt.visible = True
  pgNarrClose.[COLOR="Red"]Visible[/COLOR] = True
Linq ;0)>
 

Smokeeater

Registered User.
Local time
Today, 11:45
Joined
Jan 15, 2009
Messages
58
I solved the problem and want to post what the issue was. I was using the common terms of "Yes" in the code, when in actually Access interprets Yes as -1, and No as 0. I change "YES" to -1 and it works great!
 

David R

I know a few things...
Local time
Today, 10:45
Joined
Oct 23, 2001
Messages
2,633
Yes (without quotes) can be used interchangeably with -1, True, etc...
 

Users who are viewing this thread

Top Bottom