The code for the button is;
<% If Not rsStatus.EOF Or Not rsStatus.BOF Then %>
<a href="<%= Request.ServerVariables("SCRIPT_NAME") %>?excel=y"><img src="../img/table/print_button.gif" width="86" height="27" border="0" align="bottom"></a>
<% End If ' end Not rsStatus.EOF Or NOT rsStatus.BOF %>
With the main controller code for the export is;
<%
DIM objRS, line, filename, DateString
If Request.QueryString("excel")="y" Then
If rsStatus.EOF OR rsStatus.BOF Then
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.ActiveConnection = MM_Assist_STRING
objRS.Source = "SELECT dbo.tblJobInstructions#1.JobNumber, dbo.tblJobInstructions#1.StatusDate, dbo.tblSites.SiteName, dbo.tblSites.SiteNotes, dbo.tblFeatures.FeatureName, dbo.tblJobCategory1.JobCategory1Description, dbo.tblJobInstructions#1.JobStatus, dbo.tblJobInstructions#1.ContractIDKey FROM dbo.tblJobInstructions#1 INNER JOIN dbo.tblSites ON dbo.tblJobInstructions#1.[Site Code] = dbo.tblSites.SiteCode INNER JOIN dbo.tblFeatures ON dbo.tblJobInstructions#1.[Feature Code] = dbo.tblFeatures.FeatureCode INNER JOIN dbo.tblJobCategory1 ON dbo.tblJobInstructions#1.Category1ID = dbo.tblJobCategory1.JobCategory1ID WHERE (dbo.tblJobInstructions#1.ContractIDKey = '16') AND (dbo.tblJobInstructions#1.JobStatus = '" + Replace(rsStatus__VarStatus, "'", "''") + "')"
objRS.CursorType = 0
objRS.CursorLocation = 2
objRS.LockType = 1
objRS.Open()
DateString = Date()
DateString = Replace(Datestring, "/", "")
line=objRS.GetString(,,"[_comma_]","[_linebreak_]","")
line=Replace(line,",","¸" )
line=Replace(line,vbCrlf," ")
line=Replace(line,"[_linebreak_]",vbCr)
line=Replace(line,"[_comma_]",",")
Response.Buffer = TRUE
Response.ContentType = "application/pdf"
Response.AddHeader "Content-Disposition", "attachment; filename=" &Datestring& ".pdf"
Response.CacheControl="no-cache"
Response.Write(line)
Response.End()
End if
End if
%>