SQL Object
 
Syntax
 
SQL.RunReport ViewOrTableOrQuery[, RunNow][, OutputStyle[, ExportFileName]
 
Description
Opens a VIEW, TABLE or SELECT query as a report, or opens a previously created report.
 
The output is similar to the output option: "Report" in the SQL Designer
 
Since release V12.10.039, RunReport also opens a project of the TRADIUM Report Designer (List & Label): a list (.tlst), label (.tlbl) or card (.tcrd) project. Such a project contains its own query, so it is opened with the data as it is at that moment. With RunNow = True the print preview is shown directly, from where the report can be printed or exported (for example to PDF). This requires the user right "report designer".
 
Parameter
Description
ViewOrTableOrQuery
Since release V12.10.039, RunReport also opens a project of the TRADIUM Report Designer (List & Label): a list (.tlst), label (.tlbl) or card (.tcrd) project. Such a project contains its own query, so it is opened with the data as it is at that moment. With RunNow = True the print preview is shown directly, from where the report can be printed or exported (for example to PDF). This requires the user right "report designer".
RunNow
Boolean, default value = False.
Executes the report directly, without displaying the editor. Is only possible in combination with a previously created report.
For a Report Designer project: True shows the print preview directly. False first opens the Report Designer; the print preview follows after the designer is closed, just as with File > Open.
OutputStyle
A value of the type rptOutputStyleSettings. If RunNow = False, this value is ignored.
Here a choice is made from the output options for the report to be run directly.
Default value: rptPreview. This displays the print preview from where the other output options can also be selected.
 
rptPreview (0): print preview
rptPrintout (1): printer, with the print dialog
rptHTML (2): web page
rptDHTML (3): extended web page
rptPDFdoc (4): PDF document
rptRTFdoc (5): Rich Text Format document
rptPrintDirect (6): printer, without the print dialog
rptXLSXdoc (7): Excel workbook (.xlsx), Report Designer projects only
rptDOCXdoc (8): Word document (.docx), Report Designer projects only
 
The values 0 to 6 are the same as those of vsOutputStyleSettings, used in Printer class. So vsPreview, vsPDFdoc and so on can also be used. For a View, Table, Select query or .vrd report, rptXLSXdoc and rptDOCXdoc show the print preview.
For a Report Designer project, rptHTML creates a single file (.mht) and rptDHTML an .htm file with a folder "codebase". For every export a save dialog appears with the report name as the proposed file name; Cancel stops without output.
ExportFileName
String, optional. Report Designer projects only.
Full path and file name of the export file, for example "D:\Rapporten\Recall 15069.pdf". Use the extension that belongs to OutputStyle.
In TRADIUM: no save dialog and the file is not opened afterwards. In a server process this parameter is required for every export. An existing file is overwritten.
 
See Also
other SQL.Runxxxxxxxx methodes, Rapport.
Example
Sub Main()
 
    Dim sQuery As String
 
    sQuery = "Select * From Klanten Where Admin = 1 And Postcode Like '25%'"
    SQL.RunReport sQuery
 
End Sub

Example with previously prepared report:
Sub Main()
 
    Dim sQuery As String
 
    sQuery = "@o:\adminsql\scripts\mijn rapport.vrd"
    SQL.RunReport sQuery, True, vsPreview
 
End Sub

Example with a Report Designer project, opened directly in the print preview:
Sub Main()
 
Dim sRapport As String
sRapport = "@o:\adminsql\rapporten\voorraadlijst.tlst"
SQL.RunReport sRapport, True
SQL.RunReport sRapport, True, rptPDFdoc
SQL.RunReport sRapport, True, rptXLSXdoc
 
End Sub

Example for a scheduled task or web macro: export to PDF without a dialog, then send the file by mail:
Sub Main()
 
Dim sPDF As String
 
sPDF = "D:\Rapporten\Voorraadlijst " & Format$(Date, "yyyy-mm-dd") & ".pdf"
SQL.RunReport "@o:\adminsql\rapporten\voorraadlijst.tlst", True, rptPDFdoc, sPDF
 
If Dir$(sPDF) <> "" Then
'bijvoorbeeld als bijlage mailen
End If
 
End Sub