5

Control name of the MS Access tab with number of records

 3 years ago
source link: https://www.codesd.com/item/control-name-of-the-ms-access-tab-with-number-of-records.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Control name of the MS Access tab with number of records

advertisements

I am developing an Access database (using Office 2016) and have several tab controls which I want to display the number of records in the subform/subreport.

After a lot of searching etc I have it working for the subforms using a function which I call in the main forms current event (but in a seperate function so I can also call via a macro when I change the main forms record with a combo box, as it wasn't updating otherwise). The code I am using is:

Function ClientTotals()

Dim i As Integer
i = Form_sbfrm_ClientContacts.Recordset.RecordCount
Form_frm_Clients.ClientTabs.Pages("Contacts").Caption = "Contacts (" & i & ")"
End Function

This works perfectly for me and my tab name becomes "Contacts (No. of records)" but I can't get the syntax right to change this to work for a report, is it possible?

I have tried:

Function ClientTotals()

Dim i As Integer
i = Form_sbfrm_ClientContacts.Recordset.RecordCount
Form_frm_Clients.ClientTabs.Pages("Contacts").Caption = "Contacts (" & i & ")"

Dim j As Integer
j = Report_rpt_CurrentProjects.Recordset.RecordCount   ' this line is highlighted with the debugger
Form_frm_Clients.ClientTabs.Pages("Current Projects").Caption = "Current Projects (" & j & ")"

End Function

As well as:

Dim j As Integer
j = rpt_CurrentProjects.Report.Recordset.RecordCount  ' this line is highlighted with the debugger
Form_frm_Clients.ClientTabs.Pages("Current Projects").Caption = "Current Projects (" & j & ")"

and various others.

Another question I have is why is the syntax for the form "Form_sbfrm" etc and not using a "!". If I change to "!" it bugs out.

Thanks for your help, KAL


Recordset if you need to return complex data, if you need one value, a total or a sum, Domain functions are the way to go. Don't overdue them though, having too many on a form or a report can start to bog down usability.

Glad I can help.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK