Tabliz Doing Reports

The Art Of Data Display

Building reports with TaBliz is a two steps process:

  • Building a Template
  • Generate the Report

Building a Template

You can use the DoBaseTemplate method to generate a base template or design a template from scratch. Let’s examine how to get a base template.

dim TBLZ
dim TplPath
set TBLZ = Server.CreateObject("Tabliz.AdminRecordset")
TBLZ.DatabasePath = "C:\www_odbc\october28\tabliz2000.mdb"
TBLZ.Recordset = "MainTable"
TplPath = Request.ServerVariables("APPL_PHYSICAL_PATH") & "\template.htm"
TBLZ.DoBaseTemplate TplPath

The code above will generate a file in the path of your ASP application. (Note that if you have no write permission on the specified path you’ll get an error, also note that you can call the DoBaseTemplate method without parameter. The return value will be a string containing the Base Template) . Let’s take a look at the generated Template:

<TITLE>Main Table Report</TITLE>
</HEAD>
<BODY>
<h1><FONT face=Arial color=crimson>MainTable Report </FONT></h1>
<FONT face=Arial size=3>Use the following links to navigate through pages: <br>
<!-- TABLIZ PAGINATION --></font><br>
<FONT face=Arial size=2>In this page you can see records 
<!-- TABLIZ FIRST REC ON PAGE -->
 to <!-- TABLIZ LAST REC ON PAGE -->
 on a total of <!-- TABLIZ TOTAL REC --> </FONT><br>
<!-- TABLIZ BEGIN LOOP -->
<hr>
<h3><FONT face=Arial >This is Record number <!-- TABLIZ REC COUNT --></FONT></H3><ul>
<li><FONT face=Arial size=2>IDMainTable: {IDMainTable}</FONT><br>
<li><FONT face=Arial size=2>TextField: {TextField}</FONT><br>
</ul>
<!-- TABLIZ END LOOP -->
<FONT face=Arial size=3>Use the following links to navigate through pages: <br>
<!-- TABLIZ PAGINATION --></font><br>
<P> </P>
</BODY>
</HTML>

As you can see it is a normal HTML page with some special comment tags. This special tags will be replaced by TaBliz’s elements once the DoReport method will be called and the template is passed as parameter (we ‘ll see this later). Let’s take a look at the meaning of the special tags:

  • <!-- TABLIZ PAGINATION --> Will be replaced by page numbers
  • <!-- TABLIZ FIRST REC ON PAGE -->Will be replaced by the number corresponding to the first record on current Page
  • <!-- TABLIZ LAST REC ON PAGE -->Will be replaced by the number corresponding to the last record on current Page
  • <!-- TABLIZ TOTAL REC -->Will be replaced by the number of records in the recordset
  • <!-- TABLIZ BEGIN LOOP -->and <!-- TABLIZ END LOOP -->All the text included in this two tags will be looped for each record on page.
  • <!-- TABLIZ REC COUNT -->Inside the records loop this is a counter for the records
  • {IDMainTable} If inside the records loop the text between { and } is a field name then the field value will replace the string.

OK now that you understand the meaning of this comments you can edit the template and customize it with your favorite HTML Editor.

Generate the Report

Once you have your template buiding the report is trivial:

dim TBLZ dim TplPath 
set TBLZ = Server.CreateObject("Tabliz.AdminRecordset")
TBLZ.DatabasePath = "C:\www_odbc\october28\tabliz2000.mdb"
TBLZ.Recordset = "MainTable"
TplPath = Request.ServerVariables("APPL_PHYSICAL_PATH") & "\template.htm"
TBLZ.Report.Template.Path = TplPath
TBLZ.DoReport

I think the code is quite clear.

There are two intresting properties of the Report object that you can use: PageSize and WhereClause; the first is just the number of records per page that come out in the report, the second is a tricky parameter to filter data in the report: suppose that you wish only records with the ‘name’ field beginning with ‘a’ than you can set the property like this: TBLZ.Report.WhereClause = "WHERE NAME LIKE 'a*'"

If you know some SQL you’ll easily understand how to use this. If not... skip ...

Generate the Report as a result of the search page

Usually the results of a search performed with the TaBliz's search form are data displayed in the Editing List. If you set the property Action of the SearchForm Object to tblzShowReport (it is a constant defined in customtabliz.inc whose value is 2) then the result of the search will be displayed in a report based on the template setted as parameter of the Report.Template.Path Property. Read the search section of our site to learn more.