Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 26th, 2005, 10:31 AM
Authorized User
 
Join Date: Jun 2003
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
Default Opening a report

I have a dilemma and I have tried all possible methods and I cannot figure this out. I have a form which has a drop down list that displays the report dates. I have a view report so when the user click on the button the report will view problem is it's not opening the actual report it's opening the main form used to create the report. Here are the functions used for this report:
' --- FUNCTIONS STARTS BELOW
Function GetAgendaReport()

    dim rsAgenda, agendatype, startfileno, endfileno, filetype, status, control, requester, sponsors, startagendadate, endagendadate, startintroduceddate, endintroduceddate, notes, chkSaveReport

    ' Get Form Data
    agendatype = request("agendatype")
    startfileno = request("startfileno")
    endfileno = request("endfileno")
    filetype = request("filetype")
    status = request("status")
    control = request("control")
    requester = request("requester")
    'agendaitemnumber = request("agendaitemnumber")
    'indexes = request("agendaindexes")
    sponsors = request("agendasponsors")
    startagendadate = request("startagendadate")
    endagendadate = request("endagendadate")
    startintroduceddate = request("startintroduceddate")
    endintroduceddate = request("endintroduceddate")
    chkSaveReport = request("chkSaveReport")
    'btnAction = request("btnAction")

    ' Make Quotes SQL-Ready
    filetype = replace(filetype, "'", "''")
    status = replace(status, "'", "''")
    control = replace(control, "'", "''")
    requester = replace(requester, "'", "''")
    'agendaitemnumber = replace(agendaitemnumber, "'", "''")
    'indexes = replace(indexes, "'", "''")
    sponsors = replace(sponsors, "'", "''")
    agendatype = replace(agendatype, ", ", "','")

    set rsAgenda = server.CreateObject("adodb.recordset")
    'SQL = "select * from tblAgendaItemDetail(nolock)"
    'SQL = SQL & " where control = '" & control & "'"
    'SQL = SQL & " order by file_number"

    '"select distinct i.file_number from tblAgendaItemDetail d(nolock) " & _
    SQL = "select distinct i.file_number, d.file_type, d.status, " & _
          "d.control, d.introduced_date, d.requester, d.agenda_date, " & _
          "d.sponsors, a.agenda_type from tblAgendaItemDetail d(nolock) " & _
          "inner join tblagendaitem i(nolock) " & _
          "on d.file_number = i.file_number " & _
          "inner join tblagenda a(nolock) " & _
          "on i.meet_date_id = a.meet_date_id " & _
          "where a.agenda_type in ('" & agendatype & "')"
          'where a.agenda_type = '" & agendatype & "'"

    if startfileno <> "" and endfileno <> "" then
        if isnumeric(startfileno) and isnumeric(endfileno) then
            SQL = SQL & " and d.file_number between " & startfileno & " and " & endfileno
        end if
    end if

    if filetype <> "ALL" then
        SQL = SQL & " and d.file_type = '" & filetype & "'"
    end if

    if status <> "ALL" then
        SQL = SQL & " and d.status = '" & status & "'"
    end if

    if control <> "ALL" then
        SQL = SQL & " and d.control = '" & control & "'"
    end if

    if requester <> "ALL" then
        SQL = SQL & " and d.requester = '" & requester & "'"
    end if

    'if agendaitemnumber <> "ALL" then
       'SQL = SQL & " and d.agenda_item_number = '" & agendaitemnumber & "'"
    'end if

    'if indexes <> "ALL" then
        'SQL = SQL & " and d.indexes = '" & indexes & "'"
    'end if

    'if sponsors = "" then <== used only if user wishes to display all sponsors
    if sponsors <> "ALL" then
        'SQL = SQL & " and d.sponsors = '" & sponsors & "'"
        SQL = SQL & " and d.sponsors like '%" & sponsors & "%'"
    end if

    if startagendadate <> "" and endagendadate <> "" then
        if isdate(startagendadate) and isdate(endagendadate) then
            'she doesnt want to go by the item detail date so we are going by the agenda date in the agenda table
            'SQL = SQL & " and d.agenda_date between '" & startagendadate & "' and '" & endagendadate & "'"
            SQL = SQL & " and a.meet_date between '" & startagendadate & "' and '" & endagendadate & "'"
        end if
    end if

    if startintroduceddate <> "" and endintroduceddate <> "" then
        if isdate(startintroduceddate) and isdate(endintroduceddate) then
          SQL = SQL & " and d.introduced_date between '" & startintroduceddate & "' and '" & endintroduceddate & "'"
        end if
    end if

    'SQL = SQL & " order by i.file_number, " & request("radio2")
    'SQL = SQL & " order by " & request("radio2")
    SQL = SQL & " order by a.agenda_type, " & request("radio2")

    'Response.Write SQL
    'Response.End

    if chkSaveReport = "on" then
        savereport(SQL)
    end if

    'if btnAction = "savereport" then
       'RunSavedReport
    'end if

    'Response.Write sql
    'Response.End

    ' Run Query
    rsAgenda.open SQL, cn

    ' Return Records
    set GetAgendaReport = rsAgenda
    set rsAgenda = nothing
End Function

Function SaveReport(saveSQL)
    'local recordset
    dim rsSavedReport, sqlRpt

    set rsSavedReport = server.CreateObject("adodb.recordset")

    sqlRpt = "Select * from tblReports"
    'SQL = "insert into tblReports " & sql & "'"

    ' Run Query
    rsSavedReport.open sqlRpt, cn, 0, 3

    'response.write saveSQL
    'response.end

        ' report does not exist, add new record
        With rsSavedReport
            .addnew
            '.Fields("id") = id
        if request("filename")<> "" then
            .Fields("file_name") = filename
        end if
            .Fields("report_sql") = saveSQL
            .Fields("date_created") = now
            .update
            .close
        End With

    'Else
        ' Project already exists, display error message
        ' Response.Write "Error: Report " & strSavedReports & " already exists!"
    'End If
    set rsSavedReport = nothing
End Function

Function RunSavedReport()
    'look up saved query
    dim sqlGetSaved, rsGetSaved, sqlRunSaved

    set rsGetSaved = server.CreateObject("adodb.recordset")

    sqlGetSaved = "Select * from tblReports where id = '" & request.form("id")

    ' Get saved sql
    rsGetSaved.open sqlGetSaved

    ' save saved sql
    sqlRunSaved = rsGetSaved.Fields("sql")

    rsAgendaReport.open sqlRunSaved

    'response.write sqlRunSaved
    'response.end

    set rsGetSaved = nothing
End Function


.......

' Loop through each agenda item
if request("btnAction") = "savereport" then
  set rsAgendaReport = RunSavedReport()
else
  set rsAgendaReport = GetAgendaReport()
end if

HERE IS THE BUTTON TO SUPPOSEDLY VIEW THE REPORT:
    <input type=button name="btnAction" value="View Report" onclick="window.open('agendaitems.asp?btnAction=Sa veReport&id=' + document.frmsavedreports.id.value, 'newwindow', 'height=500,width=500, toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes,location=yes, directories=no, status=no');return false;">

Any help please I would really appreciate it's a complex project I am working on and I have to have it ready by the end of this week. Thank you

slypunk
__________________
slypunk





Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening with C# indhusundaram BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 August 2nd, 2008 01:57 AM
Application is not opening Crystal Report in Vista Suhas VB How-To 3 April 10th, 2007 05:33 AM
Opening of New Window to show a .pdf report Dilip Nagle General .NET 5 March 8th, 2007 01:25 AM
Opening an report anukagni Access 2 October 3rd, 2006 12:19 AM
Before the opening Yulon ASP.NET 1.0 and 1.1 Basics 0 October 25th, 2005 05:19 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.