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 21st, 2005, 12:29 PM
Authorized User
 
Join Date: Jun 2003
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
Default RE: Save Function

Hello I have a big problem with what I am working on. Ok I'm trying to create a function which saves the asp page by current date. I created a table named tblReports and a checkbox on the report so when the user checks the checkbox the report automatically should save in the tblReports. Here is the code I have so far but I'm not really sure how I go about solving this problem. Does anyone have any ideas? Thanks

Function SaveReport(sql)

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

    SQL = "insert into tblReports " & sql & "'"

    response.write "We are inserting " & SQL
    response.end

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

    ' Check to see if project exists
    If rsSavedReport.eof Then
        ' report does not exist, add new record
        With rsSavedReport
            .addnew
            .Fields("id") = strSavedReports
            .Fields("dateentered") = 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 searchSavedReport()

    ' Search for a report
    Set rsSavedReport = FindReport(strSavedReports)

    Response.Write sql
    Response.end

    ' Check if savereport is checked
    If rsSavedReport.eof Then
        with rsSavedReport
            .addnew
            .fields("id") = id
            .fields("file_name") = filename
            .fields("report_sql") = reportsql
            .fields("date_created") = now
            .update
        end with
    else
        id = iif(isnull(rsSavedReport("id")),0, rsSavedReport("id"))
        filename = iif(isnull(rsSavedReport("file_name")),0, rsSavedReport("file_name"))
        reportsql = iif(isnull(rsSavedReport("report_sql")),0, rsSavedReport("report_sql"))
    end if
    ' Close Objects
    rsSavedReport.close
    set rsSavedReport = nothing
end function

' --- PROCESSING LOGIC STARTS BELOW

dim strSavedReports, btnAction, rsAgendaFileNo, rsAgendaFileType, rsAgendaStatus, rsAgendaControl, rsAgendaRequester, rsAgendaReport, rsAgendaType, rsAgendaSponsors, filenumber, rsAgendaReportDetails, contactperson, currentstatus, calendardate, tmpAgendaType

strSavedReports = request("id")

' Process the Save/Search functions
btnAction = request("btnAction")
select case btnAction
   case "Save"
        ' save the report
        if strSavedReports = "on" then
            SaveReport(sql)
            ' After the save, perform a search to reload report :)
            searchSavedReport
        end if
   case ""
        ' Process the search
        if strSavedReports <> "" then
           searchSavedReport
        end if
   end select

%>
Here is the checkbox and run report button which calls the savereport function

<td nowrap>
    <b>
        <INPUT type="checkbox" name=chkSaveReport>
        Save Report
        <input type=submit name=btnAction value="Run Report">

</td>


slypunk
__________________
slypunk





Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript Function return save in XSL Variable Vrokad XSLT 2 June 2nd, 2007 02:54 AM
send variable in function to another function schoolBoy Javascript How-To 6 March 3rd, 2007 09:16 AM
How to call javascript function from VB function vinod_yadav1919 VB How-To 0 February 13th, 2006 06:03 AM
retreive function/Line from macro or function? MikoMax J2EE 0 April 1st, 2004 04:42 AM
Will not save luckychap Access 3 January 26th, 2004 01:21 PM





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