p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 26th, 2005, 11:31 AM
Authorized User
Points: 308, Level: 6
Points: 308, Level: 6 Points: 308, Level: 6 Points: 308, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Neverland, FL, USA.
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

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 02:57 AM
Application is not opening Crystal Report in Vista Suhas VB How-To 3 April 10th, 2007 06: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 01:19 AM
Before the opening Yulon ASP.NET 1.0 and 1.1 Basics 0 October 25th, 2005 06:19 AM



All times are GMT -4. The time now is 07:14 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc