• Change Tab Caption if No Data? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Change Tab Caption if No Data? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    Author
    Topic
    #450292

    I have a Form with a Tab Control

    Tab Control has two Tabs called Permits and Notes

    The two Tabs display a continous form with information from same record

    If the the current reord in the subform has no notes (memNotes) I want to change the Notes caption to no notes.

    I tried putting the following code in the SubForm

    Private Sub Form_Current()
        If Len(Me.memNotes) > 0 Then
            Me.TabCtl0.Pages(1).Caption = "NOTES"
        Else
            Me.TabCtl0.Pages(1).Caption = "no notes"
        End If
    End Sub
    

    I’m getting “Method or data member not found” error on TabCtl0

    Me.TabCtl0.Pages(1).Caption = “NOTES”

    How do I get this to work?

    Thanks, John

    Viewing 0 reply threads
    Author
    Replies
    • #1105958

      In code behind the subform, Me refers to the subform. The tab control is on the main form, I presume, so it is *not* a control on the subform. Hence, Me.TabCtl0 is not valid. You can refer to the main form from the subform as Me.Parent. Try

      Me.Parent!TabCtl0.Pages(1).Caption = …

      • #1105967

        That did it!

        I have a 3rd Tab and another SubForm with continous form, the following works OK, is there a better way?

        If Nz(DCount("lngApplicantID", "tbl_HP_MPW", _
                     "lngApplicantID=" & Me.Parent.lngApplicantID & ""), 0) > 0 Then
            Me.Parent!TabCtl0.Pages(2).Caption = "METERED PARKING"
        Else
            Me.Parent!TabCtl0.Pages(2).Caption = "no metered parking"
        End If
        
        • #1105968

          The code refers exclusively to items on the main form, so there doesn’t seem to be a reason for running it from the subform, it would be more efficient to run it from the main form (omitting .Parent, of course).

    Viewing 0 reply threads
    Reply To: Change Tab Caption if No Data? (a2k (9.0.6926) SP-3 Jet 4.0 SP-8)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: