This topic is locked

How can we created reports with variable header

10/7/2008 5:06:26 PM
ASPRunnerPro General questions
Alberto author

Hi, we have some reports that need to show the header based on one of the records from same table or a separate on.
How can we create reports with variable headers in ASPRunner?

Thanks for your help

Sergey Kornilov admin 10/7/2008

Visual Editor->Report list page. "Insert ASP code snippet" button and place your code that display custom header there.

Alberto author 10/8/2008

Great Thanks!!! <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=33762&image=1&table=forumreplies' class='bbc_emoticon' alt=':rolleyes:' />
I am not sure how to do this, is this suposed to be column by column or on a diferent way.
How the code is suposed to be done here, a litle example would be great.
Thanks

Sergey Kornilov admin 10/8/2008

It all depends on what kind of header you talking about and what you want to display there.

Alberto author 10/8/2008

I have a table with 13 columns and I will populate it with values based on a date range.

  1. If date range is Jan to Dec 2007, then each column from1 to 12 will have a Month name "Jan-07", "Feb-07", "Mar-07", "Apr-07"..."Dec" and the 13 column will be "TOTAL".
  2. If date range is Jan to Mar 2007, then each column from 1 to 3 will have a Month name "Jan-07", "Feb-07" and "Mar-07", and the 4 column will be "TOTAL". The rest of the columns stay empty
  3. It could be Nov- 2007 to Mar 2008 for example too (with max of 12 months).
    Example: Headers

    Col001 Col002 Col003 Col004

    Jan-07 Feb-07 Mar-07 TOTAL
    Example: Values

    Col01 Col02 Col03 Col04

    15000 15000 30000 60000

    20000 20000 20000 60000

    50000 10000 15000 75000

    10000 10000 10000 30000

    50000 50000 50000 150000
    Example: Result

    ----------------------------------

    Jan-07 Feb-07 Mar-07 TOTAL

    ------------------------------

    15000 15000 30000 60000

    20000 20000 20000 60000

    50000 10000 15000 75000

    10000 10000 10000 30000

    50000 50000 50000 150000
    When the records are generated, I generate a record with the headers accordingly to the date range.
    Thanks

Sergey Kornilov admin 10/10/2008

It depends on how you define the date range. Let's say range start date is stored in session variable Session("Start")
In this case you can calculate first column header as

d = CDate(Session("Start"))

Response.Write Left(MonthName(Month(d)),3) & "-" & Right(Year(d),2)


To calculate the second column header you need to add one month to range start date:

d = CDate(Session("Start"))

d = DateAdd("m", 1, d)

Response.Write Left(MonthName(Month(d)),3) & "-" & Right(Year(d),2)
Alberto author 10/13/2008

I see where you are going now, but how could this be done using sql (inseatd of session variables)?

Like I mentioned before these values are stored in a SQL table (look at headers). Date range is already used to generate the data and the headers are already generated.
If so how could I do this something like this with query?

for example:

select Col001 as "header for column1" from headers_table

select Col002 as "header for column2" from headers_table
or something lige that for all the columns that needs to be there.
Thanks <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=33894&image=1&table=forumreplies' class='bbc_emoticon' alt=':rolleyes:' />

Sergey Kornilov admin 10/13/2008

You cannot have variable dynamic headers in SQL query. This needs to be done on ASP side.

Alberto author 10/17/2008

I dont mean doing it at a sql level or database, I mean using sql queries to get the hearder stored in a table instead of doing calulations usin Session variables. . See my examples please

Thanks

J
Jane 10/20/2008

Hi,
you can replace column headers with custom events on the Visual Editor tab and select correct header from headers_table in this event.

Alberto author 10/24/2008

OK I see what you are saying , do you think you can provide an example of how to code something like that?
I have no experience doing this kind of coding yet <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=34359&image=1&table=forumreplies' class='bbc_emoticon' alt=':blink:' />
Thanks a lot Jane

J
Jane 10/31/2008

Alberto,
here is just a sample:

str = "select header_name from headers_table"

Set rstmp = server.CreateObject("ADODB.Recordset")

rstmp.open str,dbConnection
response.write rstmp("header_name")
rstmp.close

set rstmp=nothing

Alberto author 10/31/2008

Many Thanks Jane, I will give it a try <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=34646&image=1&table=forumreplies' class='bbc_emoticon' alt=':rolleyes:' />