Conditional Formatting in a Tab Control

Valery

Registered User.
Local time
Today, 05:50
Joined
Jun 22, 2013
Messages
363
Hi,
I have a Tab Control "box" on a form called PatientUpdate.

I would like to apply a conditional format on the second tab named Grp Bkg. In its properties, the Page Index is 1.

In the Tab resides a subform called Patient_GroupBooking which contains the field GroupBkg_Name.

CONDITION: if [GroupBkg_Name] is not null, make the tab Grp Bkg's font color red instead of the default black.

I have NO IDEA how to write this in Form Design Tools, Format, Conditional Formatting or other.

Thank you in advance for any assistance you generously provide.
 
I would give each tab page a name and reference the tab by its name rather than its position. You don't want to end up not being able to reorder the tabs or be stuck rewriting a lot of sequence specific code should the user want the tabs rearranged.

The following procedure is called from the load event of the form. It has more tabs than the code shows but I removed them since the code is essentially the same. Page pgIBC128New has a tab control on it so you can see that a nested tab control is no different from a top level one.

The code is intended to highlight the tabs that have data by prefixing the control label with ** for tabs where the subforms contain data. You would replace this with what ever you wanted.
Code:
Public Sub SetTabs()
    Dim pgNum As Object
    On Error GoTo Err_Proc
    For Each pgNum In Me.TabCtlTransactions.Pages
        Select Case pgNum.Name
            Case "pgIBC123"
                If IsNull(Me.sfrmIBC123.Form!VER_NO) Then
                    pgNum.Caption = "  123"
                Else
                    pgNum.Caption = "**123"
                    'this statement is here because the change event doesn't fire for the first tab and so the PPTS_ID doesn't get set
                    Me.txtPPTS_ID = DLookup("PPS_PPTS_STS_NO", "PCR_PCR_PPTS_STS", "PPCR_PRV_CHG_RQT_NO = " & Me.PPCR_PRV_CHG_RQT_NO & " And VER_NO = " & Me.sfrmIBC123.Form!VER_NO & " AND PCR_CORP_FORM_CD_NO = " & IBC123)
                End If
           Case "pgIBC128New"
                pgNum.Caption = "  128New"
                If IsNull(Me.sfrmIBC128New.Form!sfrmIBC128A1.Form!VER_NO) Then
                Else
                    pgNum.Caption = "**128"
                End If
                If IsNull(Me.sfrmIBC128New.Form!sfrmIBC128A2.Form!VER_NO) Then
                Else
                    pgNum.Caption = "**128"
                End If
                If IsNull(Me.sfrmIBC128New.Form!sfrmIBC128C.Form!VER_NO) Then
                Else
                    pgNum.Caption = "**128"
                End If
                If IsNull(Me.sfrmIBC128New.Form!sfrmIBC128D.Form!VER_NO) Then
                Else
                    pgNum.Caption = "**128"
                End If
            Case "pgIBC131"
                If IsNull(Me.sfrmIBC131.Form!VER_NO) Then
                    pgNum.Caption = "  131"
                Else
                    pgNum.Caption = "**131"
                End If
            Case "pgIBC133"
                If IsNull(Me.sfrmIBC133.Form!VER_NO) Then
                    pgNum.Caption = "  133"
                Else
                    pgNum.Caption = "**133"
                End If
        End Select
    Next pgNum
Exit_Proc:
    Exit Sub
Err_Proc:
    MsgBox Err.Number & "-" & Err.Description
    Resume Exit_Proc
End Sub
 
WOW! Intense! Will study this and give it a good try. THANK YOU VERY MUCH.
 

Users who are viewing this thread

Back
Top Bottom