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
|