you need to add code to the subform's AfterDelConfirm event.
You need a ( at the end of every tab caption.
strCaption = Left$(ctl.Parent.Caption, InStr(ctl.Parent.Caption, "(") - 1)
Yes, it's this:You are opening somewhere where ctl is as below?
Code:? ctl.Parent.Caption ? ctl.Name EtaPensione606567anniM
Note no caption, so same error as you had with no ( in the caption.
The rest is up to you.
View attachment 113822
If TypeOf ctl Is SubForm And ctl.Parent.Name <> f.Name Then
You should not be passing that?
Public Function fncRecCount(ByRef f As Form)
Otherwise add a test to ensure you have a parent before trying to use that object.
? f.Name
DipendenteM
? ctl.Parent.Caption
? ctl.Name
EtaPensione606567anniM
Try amending to
Code:If TypeOf ctl Is SubForm And ctl.Parent.Name <> f.Name Then
and then test.
'arnelgp
Public Function fncRecCount(ByRef f As Form)
Dim ctl As Control
Dim strCaption As String
Dim i As Integer
For Each ctl In f.Controls
If TypeOf ctl Is SubForm Then
strCaption = ctl.Parent.Caption
i = InStrRev(strCaption, ")")
If i <> 0 Then
strCaption = Left$(strCaption, i - 1)
End If
i = InStrRev(strCaption, "(")
If i <> 0 Then
strCaption = Left$(strCaption, i - 1)
End If
strCaption = strCaption & "(" & ctl.Form.Recordset.RecordCount & ")"
ctl.Parent.Caption = strCaption
End If
Next
End Function
here is the modified function:
Code:'arnelgp Public Function fncRecCount(ByRef f As Form) Dim ctl As Control Dim strCaption As String Dim i As Integer For Each ctl In f.Controls If TypeOf ctl Is SubForm Then strCaption = ctl.Parent.Caption i = InStrRev(strCaption, ")") If i <> 0 Then strCaption = Left$(strCaption, i - 1) End If i = InStrRev(strCaption, "(") If i <> 0 Then strCaption = Left$(strCaption, i - 1) End If strCaption = strCaption & "(" & ctl.Form.Recordset.RecordCount & ")" ctl.Parent.Caption = strCaption End If Next End Function
also i added some code on the Main form.
and on each subform (on the tab), i added another code to their Current event.
That replaces the mainform caption?
View attachment 113844
Not sure how that worked for you then?It works to me, I have name of mainform (DipendenteM), from the last attached file of arnelgp:
View attachment 113852
Not sure how that worked for you then?