Changing captions for TabCtl pages dynamically

coasterman

Registered User.
Local time
Today, 07:16
Joined
Oct 1, 2012
Messages
59
Hi,

My main form has ContactID as PK. I have a TabCtl 'TabCtlPrimary' on the main form:

i) Page 0 "pgOfficeLocations" has a sub form container "sfrmLocations" The sub form within it is a continuous form "sfrmLocations" It's PK is "LocationID" . The child/parent relationship with the main form is the ContactID PK

ii) Page 1 "pgIssuesByLocation" has a sub form container "sfrmLocationIssues" The sub form within it is a continuous sub form "sfmLocationIssues" An unbound txtBox on the main form has its control source set to the PK of which ever record has been selected in the "sfrmLocations" form. The "LocationID" is then used in the parent/child relationship for "sfrmLocationIssues".

This all works fine but I am having difficulities dynamically changing the caption for the "pgIssuesByLocation" to reflect the record count in "sfrmLocationIssues" as users select different records in the "sfrmLocations" continuous form

The desired caption is for instance "(4) Glasgow issues" or perhaps "(0) Glasgow Issues" where there are no current issues for that site.

I managed to get the caption to change on "pgIssuesbyLocation" to reflect the office location selected in "sfrmLocations" with this code

Code:
Forms!frmContacts.pgIssuesByLocation.Caption = Forms!frmContacts.txtCity & " Issues"
txtCity is of course the unbound text box whose recordsource is the linked to the selcected record in "sfrmLocations" The code is fired from the Form_Current event of "sfrmLocations"

I came across some code which looks promising but I couldn't get it to work as I needed

Code:
Private Sub Form_Current()
With Forms!frmContacts. sfrmLocationIssues.Form.RecordsetClone
If Not .EOF Then
.MoveLast
End If
Forms!frmContacts. pgIssuesByLocation.Caption = "some text [" & CStr(.RecordCount) & "]"
End With
End Sub

Again I'd added this to the Form_Current for the sfrmLocations.

It kind of works but the timing is wrong. If I select the record for Glasgow and that loaction has 3 issues the caption only chages to '3' when I select another office not when I first select in this instance the Glasgow office.

As ever any help would be appreciated.
 
Do a Dlookup to get the count in the txtCity after update event or the change event.

Then set the tab caption to include that count as well as the city in the same event code
 

Users who are viewing this thread

Back
Top Bottom