Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Record Count in Report Header

Status
Not open for further replies.

farquar

Programmer
Nov 21, 2001
14
GB
I have a report which is based on a query. I would like the record count for the result of that query, to be displayed in the Report HEADER. E.g Total number of records is 14.
I can't really do a count in my query as you need to start using group by etc. I have been able to put a count in the Detail, page footer & report footer, but not in the header.
Please help.
 
In the Report's ReportHeaderSection.OnFormat event put the following code:-

Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
rst.ActiveConnection = CurrentProject.Connection
rst.CursorType = adOpenKeyset
rst.LockType = adLockPessimistic
rst.Open Me.RecordSource

txtCount = rst.RecordCount

rst.Close


Where txtCount is the name of the text box control

If you're using DAO you'll need to translate from the ADO in opening the recordset.


'ope-that-'elps.

G LS
accessaceNOJUNK@valleyalley.co.uk
Remove the NOJUNK to use.

Please remember to give helpful posts the stars they deserve!
This makes the post more visible to others in need! :-D

 
Add a text box to your Report Header with something like this as the control source:
Code:
="Total number of records is: " & Count(*)
 
Thanks for the replies. The one about using Count(*) in the text box won't work. Count(*) will only work in the Detail or Footer Section.
 
That's not true....I've done that in the report header several times myself; plus I just tested it again and it does work!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top