Change caption of tab depending on # records

G

Guest

I have a tab control one tab of which contains a subform of related records.
I want the caption of this tab to indicate the number of records e.g. Title
(2).
I have done this in the Current event and it works ok. However, when editing
the number of records then accessing another tab on the same record, the
caption number does not change. Is there a way to detect LEAVING a tab,
rather than accessing another tab, so I only have to add the code in one
extra place. I looked in the events and it seems it does not exist?

Thanks.
 
K

Ken Snell \(MVP\)

You probably will need to repeat the code in the Change event of the Tab
control, or better put the code in a subroutine and call the subroutine from
both the (main form's) TabControlName_Change and (subform's) Form_Current
events.
 
M

Marshall Barton

mscertified said:
I have a tab control one tab of which contains a subform of related records.
I want the caption of this tab to indicate the number of records e.g. Title
(2).
I have done this in the Current event and it works ok. However, when editing
the number of records then accessing another tab on the same record, the
caption number does not change. Is there a way to detect LEAVING a tab,
rather than accessing another tab, so I only have to add the code in one
extra place. I looked in the events and it seems it does not exist?


Why not put the code in the subform's AfterInsert event so
you can update the count every time a record is added.

I suggest that you put the code in a private sub so you can
also call it from the main form's Current event.
 

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