By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,785 Members | 2,074 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,785 IT Pros & Developers. It's quick & easy.

calculated caption on tab control

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

Me.Page28.Caption = "Expenses [" & [ExpenseEntryCount] & "]"

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
'ExpenseEntryCount' 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?
Sep 27 '06 #1
Share this Question
Share on Google+
15 Replies


P: n/a
Try putting the expression you have for the ExpenseEntryCount into
Me.Page28.Caption. 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.Caption = "Expenses [" & [ExpenseEntryCount] & "]"
--
Bas Cost Budde
Holland
Sep 28 '06 #2

P: n/a
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.*********@dev.null.comwrote in message
news:ef**********@localhost.localdomain...
Try putting the expression you have for the ExpenseEntryCount into
Me.Page28.Caption. 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.Caption = "Expenses [" & [ExpenseEntryCount] & "]"

Sep 28 '06 #3

P: n/a
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
Sep 28 '06 #4

P: n/a
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.Recordsetclone
If Not .EOF Then
.MoveLast
End If
Me.Page28.Caption = "Expenses [" & CStr(.RecordCount) & "]"
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.Caption = "Expenses [" & [ExpenseEntryCount] & "]"

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
'ExpenseEntryCount' 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.com
http://www.accessmonster.com/Uwe/For...ccess/200609/1

Sep 28 '06 #5

P: n/a
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" <ri*********@hotmail.comwrote in message
news:4k******************@newssvr11.news.prodigy.c om...
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

Sep 28 '06 #6

P: n/a
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.com" <u26938@uwewrote in message
news:66f6bab16d49e@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.Recordsetclone
If Not .EOF Then
.MoveLast
End If
Me.Page28.Caption = "Expenses [" & CStr(.RecordCount) & "]"
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.Caption = "Expenses [" & [ExpenseEntryCount] & "]"

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
'ExpenseEntryCount' 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.com
http://www.accessmonster.com/Uwe/For...ccess/200609/1

Sep 28 '06 #7

P: n/a
What is the ControlSource property of the ExpenseEntryCount control now?
I guess it is some expression starting with "="; you have to put that
expression, without the "=", in place of the & [ExpenseEntryCount] &
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.*********@dev.null.comwrote in message
news:ef**********@localhost.localdomain...
>Try putting the expression you have for the ExpenseEntryCount into
Me.Page28.Caption. 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.Caption = "Expenses [" & [ExpenseEntryCount] & "]"

--
Bas Cost Budde
Holland
www.heuveltop.nl/BasCB/msac_index.html
Sep 28 '06 #8

P: n/a
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.frmPage28subform.Recordsetclone
<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.
"RefreshTabCaptions". Then in the Form_Current event of the subform itself, I
would insert a line of code such as "Call Parent.RefreshTabCaptions".

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.com
http://www.accessmonster.com/Uwe/For...ccess/200609/1

Sep 28 '06 #9

P: n/a
Well, thats a bit complicated. On the relevent page there is a subform
frmPWExpensesSubform. 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 ExpenseEntryCount that simply
references that control... =[frmPWExpensesSubform]![TotalEntries]. If I put
either [ExpenseEntryCount] or [frmPWExpensesSubform]![TotalEntries] in the
event statement ... Me.Page28.Caption = "Expenses [" & [controlname] & "]" I
get the same problem, text but no calculation.

"Bas Cost Budde" <b.*********@dev.null.comwrote in message
news:ef**********@localhost.localdomain...
What is the ControlSource property of the ExpenseEntryCount control now? I
guess it is some expression starting with "="; you have to put that
expression, without the "=", in place of the & [ExpenseEntryCount] & 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.*********@dev.null.comwrote in message
news:ef**********@localhost.localdomain...
>>Try putting the expression you have for the ExpenseEntryCount into
Me.Page28.Caption. 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.Caption = "Expenses [" & [ExpenseEntryCount] & "]"


--
Bas Cost Budde
Holland
www.heuveltop.nl/BasCB/msac_index.html

Sep 29 '06 #10

P: n/a
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.frmPage28subform.Recordsetclone
<same code as before>
End With
Tried this...
Private Sub Form_Open(Cancel As Integer)
With Me.frmPWExpensesSubform.RecordsetClone
If Not .EOF Then
.MoveLast
End If
Me.Page28.Caption = "Expenses [" & CStr(.RecordCount) & "]"
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.
"RefreshTabCaptions". Then in the Form_Current event of the subform
itself, I
would insert a line of code such as "Call Parent.RefreshTabCaptions".
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 RefreshTabCaptions()
With Me.frmPWExpensesSubform.RecordsetClone
If Not .EOF Then
.MoveLast
End If
Me.Page28.Caption = "Expenses [" & CStr(.RecordCount) & "]"
End With
End Sub

Private Sub Form_Open(Cancel As Integer)
Call Parent.RefreshTabCaptions
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
frmPWExpensesSubform. 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 ExpenseEntryCount that simply
references that control... =[frmPWExpensesSubform]![TotalEntries]. If I put
either [ExpenseEntryCount] or [frmPWExpensesSubform]![TotalEntries] in the
event statement ... Me.Page28.Caption = "Expenses [" & [controlname] & "]" I
get the same problem, text but no calculation."
Sep 29 '06 #11

P: n/a
On Fri, 29 Sep 2006 01:02:47 GMT, "Jimmy Stewart" <no**@none.comwrote:
>
>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.frmPage28subform.Recordsetclone
<same code as before>
End With

Tried this...
Private Sub Form_Open(Cancel As Integer)
With Me.frmPWExpensesSubform.RecordsetClone
If Not .EOF Then
.MoveLast
End If
Me.Page28.Caption = "Expenses [" & CStr(.RecordCount) & "]"
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.frmPWExpensesSubform.Form.RecordsetClone
If Not .EOF Then
.MoveLast
End If
Me.Page28.Caption = "Expenses [" & CStr(.RecordCount) & "]"
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
Sep 29 '06 #12

P: n/a
maybe frmPWExpensesSubform.Form.recordsetclone.recordcou nt then?

Jimmy Stewart schreef:
Well, thats a bit complicated. On the relevent page there is a subform
frmPWExpensesSubform. 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 ExpenseEntryCount that simply
references that control... =[frmPWExpensesSubform]![TotalEntries]. If I put
either [ExpenseEntryCount] or [frmPWExpensesSubform]![TotalEntries] in the
event statement ... Me.Page28.Caption = "Expenses [" & [controlname] & "]" I
get the same problem, text but no calculation.
--
Bas Cost Budde
Holland
www.heuveltop.nl/BasCB/msac_index.html
Sep 29 '06 #13

P: n/a
I see Wayne is on the same track... sounds promising.

:)
--
Bas Cost Budde
Holland
www.heuveltop.nl/BasCB/msac_index.html
Sep 29 '06 #14

P: n/a

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

Me.Page28.Caption = "Expenses [" & [ExpenseEntryCount] & "]"

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
'ExpenseEntryCount' 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.

Sep 29 '06 #15

P: n/a
Thanks for that Wayne, yes apologies for leading you astray there - I was
typing untested code directly into this message and neglected to include the
".Form" property - will try to re-read before posting in future!

Wayne Gillespie wrote:
>>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
[quoted text clipped - 17 lines]
>>
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.frmPWExpensesSubform.Form.RecordsetClone
If Not .EOF Then
.MoveLast
End If
Me.Page28.Caption = "Expenses [" & CStr(.RecordCount) & "]"
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
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200609/1

Sep 30 '06 #16

This discussion thread is closed

Replies have been disabled for this discussion.