We have used this code to allow us to either Preview, Print, EMail or Save to File any report in our application.
'start of reportprint code
FUNCTION REPORTPRINT AS C (VAR->PRINTREPORT AS C )
DIM PRINTTYPE as c
PRINTTYPE = ui_get_radio("Select Report type","Preview","Preview","Print","E-Mail","Save to File")
IF VAR->PRINTTYPE = "Preview" THEN
'Preview a report, label, letter, form or browse layout. You can specify which records to preview.
query.filter = ""
query.order = ""
:Report.Preview(VAR->PRINTREPORT,query.filter,query.order)
END IF
IF VAR->PRINTTYPE = "Print" THEN
'Print a report, label, letter, form or browse layout. You can specify which records to print.
query.filter = ""
query.order = ""
:Report.Print(VAR->PRINTREPORT,query.filter,query.order)
END IF
IF VAR->PRINTTYPE = "E-Mail" THEN
'Send a report, label, letter, form or browse layout as an attachment to an e-mail message. You can specify which records to send.
query.filter = ""
query.order = ""
to_param = a5_eval_expression("")
cc_param = a5_eval_expression("")
bcc_param = a5_eval_expression("")
subject_param = a5_eval_expression("")
message_param = a5_eval_expression("")
'IF VAR->EMAILCLIENT = "DEFAULT"
' :Report.Send(VAR->PRINTREPORT,"PDF",query.filter,query.order,"default",to_param,subject_param,message_param,cc_param,bcc_param)
'ELSE
'July,9 2007 rev org line :Report.send(VAR->PRINTREPORT,"PDF",query.filter,query.order,"a5")
:Report.send(VAR->PRINTREPORT,"PDF",query.filter,query.order,"default")
'END IF
END IF
IF VAR->PRINTTYPE = "Save to File" THEN
'Save a report, label, letter, form or browse to an Acrobat, Rich Text, HTML or Plain Text file. You can specify which records to save.
query.filter = ""
query.order = ""
:Report.SaveAs(VAR->PRINTREPORT,"PDF",query.filter,query.order,"",.T.)
END IF
END FUNCTION
'end of reportprint code
A typical button on a Form to access a report called "Eq_Warr" looks like
REPORTPRINT("Eq_Warr")
This has worked for us since v5 or so, but now when I choose to EMail a report (Eudora) then cancel the action within the EMail app and go back & select PREVIEW the same report, I end up with GARBAGE in the Preview screen. See attachments.
I am sure I have left a lot out of this explanation so please ask & I will do my best to reply.
Any ideas why or how to fix? Much appreciated.
'start of reportprint code
FUNCTION REPORTPRINT AS C (VAR->PRINTREPORT AS C )
DIM PRINTTYPE as c
PRINTTYPE = ui_get_radio("Select Report type","Preview","Preview","Print","E-Mail","Save to File")
IF VAR->PRINTTYPE = "Preview" THEN
'Preview a report, label, letter, form or browse layout. You can specify which records to preview.
query.filter = ""
query.order = ""
:Report.Preview(VAR->PRINTREPORT,query.filter,query.order)
END IF
IF VAR->PRINTTYPE = "Print" THEN
'Print a report, label, letter, form or browse layout. You can specify which records to print.
query.filter = ""
query.order = ""
:Report.Print(VAR->PRINTREPORT,query.filter,query.order)
END IF
IF VAR->PRINTTYPE = "E-Mail" THEN
'Send a report, label, letter, form or browse layout as an attachment to an e-mail message. You can specify which records to send.
query.filter = ""
query.order = ""
to_param = a5_eval_expression("")
cc_param = a5_eval_expression("")
bcc_param = a5_eval_expression("")
subject_param = a5_eval_expression("")
message_param = a5_eval_expression("")
'IF VAR->EMAILCLIENT = "DEFAULT"
' :Report.Send(VAR->PRINTREPORT,"PDF",query.filter,query.order,"default",to_param,subject_param,message_param,cc_param,bcc_param)
'ELSE
'July,9 2007 rev org line :Report.send(VAR->PRINTREPORT,"PDF",query.filter,query.order,"a5")
:Report.send(VAR->PRINTREPORT,"PDF",query.filter,query.order,"default")
'END IF
END IF
IF VAR->PRINTTYPE = "Save to File" THEN
'Save a report, label, letter, form or browse to an Acrobat, Rich Text, HTML or Plain Text file. You can specify which records to save.
query.filter = ""
query.order = ""
:Report.SaveAs(VAR->PRINTREPORT,"PDF",query.filter,query.order,"",.T.)
END IF
END FUNCTION
'end of reportprint code
A typical button on a Form to access a report called "Eq_Warr" looks like
REPORTPRINT("Eq_Warr")
This has worked for us since v5 or so, but now when I choose to EMail a report (Eudora) then cancel the action within the EMail app and go back & select PREVIEW the same report, I end up with GARBAGE in the Preview screen. See attachments.
I am sure I have left a lot out of this explanation so please ask & I will do my best to reply.
Any ideas why or how to fix? Much appreciated.
Comment