We also declare, then set variables through an x-basic dialog. Attached is the dialog box, and what follows is the code. We use this to filter the reports. I pass the global date variables into the report where they are also defined, then create calc fields using those global variables. The filter in the report is based on these calc fields. I don't know your experience level with x-basic, so don't take this wrong. The code may seem a bit overwhelming, but it is actually pretty straightforward, and it will accomplish what you need.
Code:
'Date Created: 16-Apr-2007 03:38:47 PM 'Last Updated: 17-Apr-2007 02:17:38 PM 'Created By : 'Updated By : 'Create an XDialog dialog box to prompt for parameters. DIM SHARED report_sel as C DIM GLOBAL Start_date as D DIM GLOBAL end_date as D DIM SHARED Vendor as C DIM GLOBAL Vend_no as C DIM SHARED varC_result as C report_sel="" Start_date={} end_date={} Vendor="" varC_result="" again: Vend_no="" ok_button_label = "&OK" cancel_button_label = "&Cancel" varC_result = ui_dlg_box("Post TANF Wrap Around System Reports",<<%dlg% {frame=1,1 Reports} {region}Please select a report to print:{endregion}{sp} {region}(report_sel:Monthly Paid Detail); (report_sel:Total Paid Summary); (report_sel:Vendor Payment Summary); {endregion}; ; {frame=1,1 Dates} {region2} Please Enter Begin Date:| [%DATE;P=popup.calendar(dtoc(Start_date));I=popup.calendar%.20Start_date!Start_date_*]; Please Enter End Date:| [%DATE;P=popup.calendar(dtoc(end_date));I=popup.calendar%.20end_date!end_date_*]; {endregion2}; {condition=(report_sel="Vendor Payment Summary")} {frame=1,1 Vendor Information} {region3}For One Vendor or All Vendors:{endregion} {region}(Vendor:All Vendors); (Vendor:One Vendor); ; {condition=(Vendor="One Vendor")} Enter Vendor Number:| [.10Vend_no] {endregion3}; ; {condition=.t.} {line=1,0}; {region} <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL> {endregion}; %dlg%,<<%code% if left(a_dlg_button,11) = "Start_date_" then if a_dlg_button = "Start_date_killfocus" then Start_date = ctod(dtoc(Start_date)) end if a_dlg_button = "" end if if left(a_dlg_button,9) = "end_date_" then if a_dlg_button = "end_date_killfocus" then end_date = ctod(dtoc(end_date)) end if a_dlg_button = "" end if %code%) if varC_result= "CANCEL" ui_msg_box("Post TANF Wrap Around System","Action Cancelled at user request") end end if if start_date = {} .or. end_date = {} ui_msg_box("Post TANF Wrap Around System","Dates cannot be blank"+chr(13)+chr(13)+"Please Enter dates") goto again end if if end_date < start_date ui_msg_box("Post TANF Wrap Around System","End Date cannot be earlier than Start Date"+chr(13)+chr(13)+"Please Re-enter dates") end_date={} goto again end if if vendor = "One Vendor" .and. Vend_no="" ui_msg_box("Post TANF Wrap Around System","Vendor Number is missing"+chr(13)+chr(13)+"Please Enter Vendor Number") goto again end if debugcheck() if vendor = "One Vendor" .and. Vend_no<>"" dim Global Vendor_num as N vendor_num = val(vend_no) if .not.exist(vendor_num,"vendor","Vendor_No") ui_msg_box("Post TANF Wrap Around System","Vendor Number "+vend_no+" is invalid"+chr(13)+chr(13)+"Please Enter a valid Vendor Number") goto again end if end if 'now that we've got everything, let's print the report 'variables: "rep_select"= selected report ' "Start_date"= begin date for report ' "End_date" = ending date for report ' "Vendor_num" = Vendor Number for Individual Vendor Summary if Vendor = "One Vendor" query.filter = replace_parameters("Vendor->vendor_no = [varN->Vendor_num]",local_variables()) else query.filter = "" end if query.order = "" if level = "A" :Report.Preview(report_sel,query.filter,query.order) else :Report.Print(report_sel,query.filter,query.order) end if end
Leave a comment: