calculated caption on tab control

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jimmy Stewart

    #1

    calculated caption on tab control

    I want to use a calculated function for the caption on my tab controls. I
    used the following code:

    Me.Page28.Capti on = "Expenses [" & [ExpenseEntryCou nt] & "]"

    This should display the following: " Expenses [10] " where 10 is the number
    of expenses on that page. On my form I have a calculated control named
    'ExpenseEntryCo unt' that correctly displayd this information.

    If I place this code in the forms OnOpen, OnActivate or OnCurrent event,
    when the form is opened the tab reads " Expenses [] " with no number in the
    brackets. If however, I place this same code in the onClick event for the
    tab control, when I click the blank space to the right of the tabs, the
    caption changes from " Expenses [] " to " Expenses [10] ". If I put that
    same code in the OnClick event for the actual page, it does not work. What
    gives? Am I doing something wrong or am I attempting an impossible feat?


  • Bas Cost Budde

    #2
    Re: calculated caption on tab control

    Try putting the expression you have for the ExpenseEntryCou nt into
    Me.Page28.Capti on. The calculated control seems to be too late.

    Jimmy Stewart schreef:
    I want to use a calculated function for the caption on my tab controls. I
    used the following code:
    >
    Me.Page28.Capti on = "Expenses [" & [ExpenseEntryCou nt] & "]"
    --
    Bas Cost Budde
    Holland

    Comment

    • Jimmy Stewart

      #3
      Re: calculated caption on tab control

      I'm not sure I understand what your saying. I have tried to put that code in
      the OnOpen event of the form and the caption text is correct but the
      calculation is not made.

      "Bas Cost Budde" <b.costbudde@de v.null.comwrote in message
      news:effmki$k71 $1@localhost.lo caldomain...
      Try putting the expression you have for the ExpenseEntryCou nt into
      Me.Page28.Capti on. The calculated control seems to be too late.
      >
      Jimmy Stewart schreef:
      >I want to use a calculated function for the caption on my tab controls. I
      >used the following code:
      >>
      >Me.Page28.Capt ion = "Expenses [" & [ExpenseEntryCou nt] & "]"
      >

      Comment

      • Rick Brandt

        #4
        Re: calculated caption on tab control

        Jimmy Stewart wrote:
        I'm not sure I understand what your saying. I have tried to put that
        code in the OnOpen event of the form and the caption text is correct
        but the calculation is not made.
        Have you tried the Current event?

        --
        Rick Brandt, Microsoft Access MVP
        Email (as appropriate) to...
        RBrandt at Hunter dot com


        Comment

        • RichardP via AccessMonster.com

          #5
          Re: calculated caption on tab control

          I think this is one of those things where the calculated control on screen
          ambles along a little while after the form has initialised or been
          recalculated.

          The method I've used in the past, that you might consider trying is as
          follows:

          With Me.Recordsetclo ne
          If Not .EOF Then
          .MoveLast
          End If
          Me.Page28.Capti on = "Expenses [" & CStr(.RecordCou nt) & "]"
          End With


          Jimmy Stewart wrote:
          >I want to use a calculated function for the caption on my tab controls. I
          >used the following code:
          >
          >Me.Page28.Capt ion = "Expenses [" & [ExpenseEntryCou nt] & "]"
          >
          >This should display the following: " Expenses [10] " where 10 is the number
          >of expenses on that page. On my form I have a calculated control named
          >'ExpenseEntryC ount' that correctly displayd this information.
          >
          >If I place this code in the forms OnOpen, OnActivate or OnCurrent event,
          >when the form is opened the tab reads " Expenses [] " with no number in the
          >brackets. If however, I place this same code in the onClick event for the
          >tab control, when I click the blank space to the right of the tabs, the
          >caption changes from " Expenses [] " to " Expenses [10] ". If I put that
          >same code in the OnClick event for the actual page, it does not work. What
          >gives? Am I doing something wrong or am I attempting an impossible feat?
          --
          Message posted via AccessMonster.c om


          Comment

          • Jimmy Stewart

            #6
            Re: calculated caption on tab control

            From my original post:

            "If I place this code in the forms OnOpen, OnActivate or OnCurrent event,
            when the form is opened the tab reads " Expenses [] " with no number in the
            brackets."

            "Rick Brandt" <rickbrandt2@ho tmail.comwrote in message
            news:4kOSg.1931 9$IA.16539@news svr11.news.prod igy.com...
            Jimmy Stewart wrote:
            >I'm not sure I understand what your saying. I have tried to put that
            >code in the OnOpen event of the form and the caption text is correct
            >but the calculation is not made.
            >
            Have you tried the Current event?
            >
            --
            Rick Brandt, Microsoft Access MVP
            Email (as appropriate) to...
            RBrandt at Hunter dot com
            >

            Comment

            • Jimmy Stewart

              #7
              Re: calculated caption on tab control

              What exactly is that code doing? I placed it in the onopen event of the form
              and got some very wrong numbers between the brackets.

              "RichardP via AccessMonster.c om" <u26938@uwewrot e in message
              news:66f6bab16d 49e@uwe...
              >I think this is one of those things where the calculated control on screen
              ambles along a little while after the form has initialised or been
              recalculated.
              >
              The method I've used in the past, that you might consider trying is as
              follows:
              >
              With Me.Recordsetclo ne
              If Not .EOF Then
              .MoveLast
              End If
              Me.Page28.Capti on = "Expenses [" & CStr(.RecordCou nt) & "]"
              End With
              >
              >
              Jimmy Stewart wrote:
              >>I want to use a calculated function for the caption on my tab controls. I
              >>used the following code:
              >>
              >>Me.Page28.Cap tion = "Expenses [" & [ExpenseEntryCou nt] & "]"
              >>
              >>This should display the following: " Expenses [10] " where 10 is the
              >>number
              >>of expenses on that page. On my form I have a calculated control named
              >>'ExpenseEntry Count' that correctly displayd this information.
              >>
              >>If I place this code in the forms OnOpen, OnActivate or OnCurrent event,
              >>when the form is opened the tab reads " Expenses [] " with no number in
              >>the
              >>brackets. If however, I place this same code in the onClick event for the
              >>tab control, when I click the blank space to the right of the tabs, the
              >>caption changes from " Expenses [] " to " Expenses [10] ". If I put that
              >>same code in the OnClick event for the actual page, it does not work.
              >>What
              >>gives? Am I doing something wrong or am I attempting an impossible feat?
              >
              --
              Message posted via AccessMonster.c om

              >

              Comment

              • Bas Cost Budde

                #8
                Re: calculated caption on tab control

                What is the ControlSource property of the ExpenseEntryCou nt control now?
                I guess it is some expression starting with "="; you have to put that
                expression, without the "=", in place of the & [ExpenseEntryCou nt] &
                part of the Caption property's controlsource.

                Jimmy Stewart schreef:
                I'm not sure I understand what your saying. I have tried to put that code in
                the OnOpen event of the form and the caption text is correct but the
                calculation is not made.
                >
                "Bas Cost Budde" <b.costbudde@de v.null.comwrote in message
                news:effmki$k71 $1@localhost.lo caldomain...
                >Try putting the expression you have for the ExpenseEntryCou nt into
                >Me.Page28.Capt ion. The calculated control seems to be too late.
                >>
                >Jimmy Stewart schreef:
                >>I want to use a calculated function for the caption on my tab controls. I
                >>used the following code:
                >>>
                >>Me.Page28.Cap tion = "Expenses [" & [ExpenseEntryCou nt] & "]"
                >
                >
                --
                Bas Cost Budde
                Holland

                Comment

                • RichardP via AccessMonster.com

                  #9
                  Re: calculated caption on tab control

                  The code is taking a copy of the recordset source for your current form,
                  moving to the end of the recordset to ensure that the recordcount is accurate,
                  and then displaying the result of the recordcount in your caption.

                  However, this is making an assumption that the recordcount you wish to
                  display is the one of your main form. If the recordcount required is the one
                  of a subform embedded in your one of your tab pages, you would need to adapt
                  accordingly, e.g.

                  With Me.frmPage28sub form.Recordsetc lone
                  <same code as before>
                  End With

                  Off the top of my head (and reading between the lines of what you're saying
                  you're doing), I would probably put this into its own public procedure - e.g.
                  "RefreshTabCapt ions". Then in the Form_Current event of the subform itself, I
                  would insert a line of code such as "Call Parent.RefreshT abCaptions".

                  You've not said what the expression is in your calculated control which
                  determines the record count, so I've no way of estimating why you've received
                  'very wrong' numbers.


                  Jimmy Stewart wrote:
                  >What exactly is that code doing? I placed it in the onopen event of the form
                  >and got some very wrong numbers between the brackets.
                  >
                  >>I think this is one of those things where the calculated control on screen
                  >ambles along a little while after the form has initialised or been
                  >[quoted text clipped - 29 lines]
                  >>>What
                  >>>gives? Am I doing something wrong or am I attempting an impossible feat?
                  --
                  Message posted via AccessMonster.c om


                  Comment

                  • Jimmy Stewart

                    #10
                    Re: calculated caption on tab control

                    Well, thats a bit complicated. On the relevent page there is a subform
                    frmPWExpensesSu bform. On this subform is a calculated control named
                    TotalEntries to count the number of records... =Count([Description]). Then
                    on the main form I have a control named ExpenseEntryCou nt that simply
                    references that control... =[frmPWExpensesSu bform]![TotalEntries]. If I put
                    either [ExpenseEntryCou nt] or [frmPWExpensesSu bform]![TotalEntries] in the
                    event statement ... Me.Page28.Capti on = "Expenses [" & [controlname] & "]" I
                    get the same problem, text but no calculation.

                    "Bas Cost Budde" <b.costbudde@de v.null.comwrote in message
                    news:efgb9g$qbr $1@localhost.lo caldomain...
                    What is the ControlSource property of the ExpenseEntryCou nt control now? I
                    guess it is some expression starting with "="; you have to put that
                    expression, without the "=", in place of the & [ExpenseEntryCou nt] & part
                    of the Caption property's controlsource.
                    >
                    Jimmy Stewart schreef:
                    >I'm not sure I understand what your saying. I have tried to put that code
                    >in the OnOpen event of the form and the caption text is correct but the
                    >calculation is not made.
                    >>
                    >"Bas Cost Budde" <b.costbudde@de v.null.comwrote in message
                    >news:effmki$k7 1$1@localhost.l ocaldomain...
                    >>Try putting the expression you have for the ExpenseEntryCou nt into
                    >>Me.Page28.Cap tion. The calculated control seems to be too late.
                    >>>
                    >>Jimmy Stewart schreef:
                    >>>I want to use a calculated function for the caption on my tab controls.
                    >>>I used the following code:
                    >>>>
                    >>>Me.Page28.Ca ption = "Expenses [" & [ExpenseEntryCou nt] & "]"
                    >>
                    >>
                    >
                    --
                    Bas Cost Budde
                    Holland
                    www.heuveltop.nl/BasCB/msac_index.html

                    Comment

                    • Jimmy Stewart

                      #11
                      Re: calculated caption on tab control

                      However, this is making an assumption that the recordcount you wish to
                      display is the one of your main form. If the recordcount required is the
                      one
                      of a subform embedded in your one of your tab pages, you would need to
                      adapt
                      accordingly, e.g.
                      >
                      With Me.frmPage28sub form.Recordsetc lone
                      <same code as before>
                      End With
                      Tried this...
                      Private Sub Form_Open(Cance l As Integer)
                      With Me.frmPWExpense sSubform.Record setClone
                      If Not .EOF Then
                      .MoveLast
                      End If
                      Me.Page28.Capti on = "Expenses [" & CStr(.RecordCou nt) & "]"
                      End With

                      but no can do, Access doesn't like that...
                      >
                      Off the top of my head (and reading between the lines of what you're
                      saying
                      you're doing), I would probably put this into its own public procedure -
                      e.g.
                      "RefreshTabCapt ions". Then in the Form_Current event of the subform
                      itself, I
                      would insert a line of code such as "Call Parent.RefreshT abCaptions".
                      Tried this also but access says there is an invalid reference to the parent
                      property. I've never used a public function before so I may be doing
                      something wrong that is easily correctable!?

                      Public Sub RefreshTabCapti ons()
                      With Me.frmPWExpense sSubform.Record setClone
                      If Not .EOF Then
                      .MoveLast
                      End If
                      Me.Page28.Capti on = "Expenses [" & CStr(.RecordCou nt) & "]"
                      End With
                      End Sub

                      Private Sub Form_Open(Cance l As Integer)
                      Call Parent.RefreshT abCaptions
                      End Sub
                      You've not said what the expression is in your calculated control which
                      determines the record count, so I've no way of estimating why you've
                      received
                      'very wrong' numbers.
                      >
                      From posting in this same thread following a different line of thinking...

                      "Well, thats a bit complicated. On the relevent page there is a subform
                      frmPWExpensesSu bform. On this subform is a calculated control named
                      TotalEntries to count the number of records... =Count([Description]). Then
                      on the main form I have a control named ExpenseEntryCou nt that simply
                      references that control... =[frmPWExpensesSu bform]![TotalEntries]. If I put
                      either [ExpenseEntryCou nt] or [frmPWExpensesSu bform]![TotalEntries] in the
                      event statement ... Me.Page28.Capti on = "Expenses [" & [controlname] & "]" I
                      get the same problem, text but no calculation."


                      Comment

                      • Wayne Gillespie

                        #12
                        Re: calculated caption on tab control

                        On Fri, 29 Sep 2006 01:02:47 GMT, "Jimmy Stewart" <none@none.comw rote:
                        >
                        >However, this is making an assumption that the recordcount you wish to
                        >display is the one of your main form. If the recordcount required is the
                        >one
                        >of a subform embedded in your one of your tab pages, you would need to
                        >adapt
                        >accordingly, e.g.
                        >>
                        > With Me.frmPage28sub form.Recordsetc lone
                        > <same code as before>
                        > End With
                        >
                        >Tried this...
                        >Private Sub Form_Open(Cance l As Integer)
                        With Me.frmPWExpense sSubform.Record setClone
                        If Not .EOF Then
                        .MoveLast
                        End If
                        Me.Page28.Capti on = "Expenses [" & CStr(.RecordCou nt) & "]"
                        End With
                        >
                        >but no can do, Access doesn't like that...
                        You are not referencing the subform correctly, you are referencing the subform
                        control, NOT the subform contained within the control. You need to add .Form.
                        before the RecordsetClone -

                        With Me.frmPWExpense sSubform.Form.R ecordsetClone
                        If Not .EOF Then
                        .MoveLast
                        End If
                        Me.Page28.Capti on = "Expenses [" & CStr(.RecordCou nt) & "]"
                        End With

                        I would try this code on the Form_Load event as the subform data may not have
                        been loaded fully when the Form_Open event fires.


                        Wayne Gillespie
                        Gosford NSW Australia

                        Comment

                        • Bas Cost Budde

                          #13
                          Re: calculated caption on tab control

                          maybe frmPWExpensesSu bform.Form.reco rdsetclone.reco rdcount then?

                          Jimmy Stewart schreef:
                          Well, thats a bit complicated. On the relevent page there is a subform
                          frmPWExpensesSu bform. On this subform is a calculated control named
                          TotalEntries to count the number of records... =Count([Description]). Then
                          on the main form I have a control named ExpenseEntryCou nt that simply
                          references that control... =[frmPWExpensesSu bform]![TotalEntries]. If I put
                          either [ExpenseEntryCou nt] or [frmPWExpensesSu bform]![TotalEntries] in the
                          event statement ... Me.Page28.Capti on = "Expenses [" & [controlname] & "]" I
                          get the same problem, text but no calculation.
                          --
                          Bas Cost Budde
                          Holland

                          Comment

                          • Bas Cost Budde

                            #14
                            Re: calculated caption on tab control

                            I see Wayne is on the same track... sounds promising.

                            :)
                            --
                            Bas Cost Budde
                            Holland

                            Comment

                            • phnz@mailspeed.net

                              #15
                              Re: calculated caption on tab control


                              Jimmy Stewart wrote:
                              I want to use a calculated function for the caption on my tab controls. I
                              used the following code:
                              >
                              Me.Page28.Capti on = "Expenses [" & [ExpenseEntryCou nt] & "]"
                              >
                              This should display the following: " Expenses [10] " where 10 is the number
                              of expenses on that page. On my form I have a calculated control named
                              'ExpenseEntryCo unt' that correctly displayd this information.
                              >
                              If I place this code in the forms OnOpen, OnActivate or OnCurrent event,
                              when the form is opened the tab reads " Expenses [] " with no number in the
                              brackets. If however, I place this same code in the onClick event for the
                              tab control, when I click the blank space to the right of the tabs, the
                              caption changes from " Expenses [] " to " Expenses [10] ". If I put that
                              same code in the OnClick event for the actual page, it does not work. What
                              gives? Am I doing something wrong or am I attempting an impossible feat?
                              Suggestion: Try using DCount instead of a separate calculated
                              control. Should solve your problem.

                              Comment

                              Working...