IpeXeuS
03-15-2007, 01:49 AM
Hello there, :)
Is it possible to calculate total report records in page header? All advices and tips are very welcome and well approciated. :cool:
Dennisk
03-15-2007, 02:22 AM
you can place code in the report header - on print event. So I presume you could run an sql statement to calculate the total.
OR
use a function in a text box in the header that does the same thing.
IpeXeuS
03-15-2007, 02:41 AM
I added following rowsource "=Count([Field_In_Details])" to textbox object in page header and it didn't work at all, but in report header it works well, but in my case it cant be there, so...
Dennisk
03-15-2007, 03:19 AM
use a function in your page header
create a text box and set the source to
=myFunction()
in myFunction declare a recordset and use an SQL statement that gurantees to return one row ie your count, assign that value to the name of your function, and that value should appear on each page header.
IpeXeuS
03-15-2007, 04:58 AM
Ok, will try that. But can you plz give me a short sample code for that, cause vba aint so familiar to me.
Dennisk
03-15-2007, 06:11 AM
in DAO
public function GetCountOfTable() as Integer
dim rst as DAO.Recordset
on error goto Err_Handler:
set rst=CurrentDB.Openrecordset("Select count(*) as MaxCount from yourTable")
if not rst.eof then
GetCountOfTable=rst("MaxCount")
endif
Exit_Handler:
rst.close
set rst=nothing
exit function
Err_Handler:
msgbox err & " " & err.description
resusme exit_Handler
end function
IpeXeuS
03-15-2007, 06:23 AM
Thanks for the sample code chap... :)
IpeXeuS
03-15-2007, 06:56 AM
I tryied that code and it sure works, but that wasn't quite what I try to complish here. User is able to select a filter from list (linked to table), before report can be previewed and printed. Basicly I try to count records in report and not in table, so is there anything I need to change in that code over there? Cheers!
IpeXeuS
03-15-2007, 11:31 PM
Help needed over here mates, thank you. :)