tabcontrol page caption

J

JohnE

I have a mainform with a tabcontrol on it. On one of the tab controls is a
subform in continous style. I would like to have that tab page caption
indicate how many items are in the subform. An example is Children (0) or
Children (4) and so on. This would change each time a new record on the
mainform is selected.

Don't worry about proper naming until I get this to work.

I have placed an unbound textbox in the header of the subform with an
expression of =count[(ID)] as a control source. This works and counts the
number of rows in the subform. The default value is given 0.

I then placed an unbound text box on the main form and gave it an expression
of =[sfrmProjectChangeRequest_Subform].[Form]![Text14] as its control source.
This works and pulls in the number from the subform. This does pull in the
number from the subform, unless the subform does not have any items to count.
Or at least that is the error message I get.

In the mainform's On_Current event I am trying the following;

If Me.Text233.Value > 0 Then
Me.TabCtl195.Pages("Page232").Caption = "Children " & "(" &
Me.Text233 & ")"
Else
Me.TabCtl195.Pages("Page232").Caption = "Children (0)"
End If

But it seems to error out on the If line. The message indicates that I've
entered an expression that has no value.

Can anyone help out on this? Or if there is a better way of doing the
caption, let me know.

Thanks...John
 
M

Marshall Barton

JohnE said:
I have a mainform with a tabcontrol on it. On one of the tab controls is a
subform in continous style. I would like to have that tab page caption
indicate how many items are in the subform. An example is Children (0) or
Children (4) and so on. This would change each time a new record on the
mainform is selected.

Don't worry about proper naming until I get this to work.

I have placed an unbound textbox in the header of the subform with an
expression of =count[(ID)] as a control source. This works and counts the
number of rows in the subform. The default value is given 0.

I then placed an unbound text box on the main form and gave it an expression
of =[sfrmProjectChangeRequest_Subform].[Form]![Text14] as its control source.
This works and pulls in the number from the subform. This does pull in the
number from the subform, unless the subform does not have any items to count.
Or at least that is the error message I get.

In the mainform's On_Current event I am trying the following;

If Me.Text233.Value > 0 Then
Me.TabCtl195.Pages("Page232").Caption = "Children " & "(" &
Me.Text233 & ")"
Else
Me.TabCtl195.Pages("Page232").Caption = "Children (0)"
End If

But it seems to error out on the If line. The message indicates that I've
entered an expression that has no value.


Control source expression calculations VBA code are
asynchronous activities so you can not mix the two.

I suggest that you try somethng like this in the main form's
Current event:

With Me.sfrmProjectChangeRequest_Subform.Form.RecordsetClone
If .RecordCount > 0 Then .MoveLast
Me.TabCtl195.Pages("Page232").Caption = "Children (" _
& .RecordCount & ")"
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top