;Get previous month to date and put into queries. Allows changes ; Sorry, but I'm the world's worst at commenting my programs properly method run(var eventInfo Event) var EDt, BDt, TDt, YDt date Queer query PrintOut report TC tCursor Mess string FullMonth array[12] string Frm form LEDt,LBDt date ;last year's date range Flag logical Yr,Mn,Da longInt ;year and month of last month BDate,EDate string ;strings for beginning and ending dates a,b,c,d string r,s,t,u number InTbl,OutTbl tCursor Tbl table RP report endVar const Days=string ("312831303130313130313031") endConst TDt=today() ;today's date Yr=year(TDt) Mn=month(TDt) Mn=Mn-1 if Mn<1 then Mn=12 Yr=Yr-1 if Yr<0 then Yr=1999 endif endif d=substr(Days,Mn*2-1,2) a=strVal(Mn) b=strVal(Yr) EDt= date(a+"/"+d+"/"+b) BDt= date(a+"/01/"+b) Flag=true while Flag=true BDt.view("Enter Begin Date") EDt.view("Enter End Date") if BDt>EDt or BDt< date("01/01/90") or EDt< date("01/01/90") then msgInfo("Date Error","End date cannot come before Begin date") else Flag=false a=msgQuestion("From: "+string(BDt)+" To: "+string(EDt),"Is this correct?") if a="No" or a="Cancel" then Flag=true endif endif endWhile Mn=month(EDt) ;get last years range for historical data Yr=Yr-1 if Yr<0 then Yr=1999 endif d=substr(Days,Mn*2-1,2) a=strVal(Mn) b=strVal(Yr) LEDt=date(a+"/"+d+"/"+b) LBDt=date("01/01/"+b) errorTrapOnWarnings(yes) Frm.open("Messages") EDate=string(EDt) BDate=string(BDt) FullMonth[1]="January" FullMonth[2]="February" FullMonth[3]="March" FullMonth[4]="April" FullMonth[5]="May" FullMonth[6]="June" FullMonth[7]="July" FullMonth[8]="August" FullMonth[9]="September" FullMonth[10]="October" FullMonth[11]="November" FullMonth[12]="December" RP.load(":AmerTech:AmerTech") RP.DateText=FullMonth[Mn] RP.close() Frm.Messages=FullMonth[Mn] Frm.Messages="Querying OrderHis" Queer= Query ANSWER: :AmerTech:AmerTech.DB :WORK:INVSTATS.DB | Cusnum | Invdate | Statecode | Ordernum | | _EG01 | >=~BDt,<=~EDt | Check as State | _EG02 | :WORK:CUSTOMER.DB | CUSNUM | NAME | | _EG01 | =ameritech.. | :WORK:ORDERHIS.DB | Ordnum | Index | Ponum | Qty | Price | | Check _EG02 | Check <100,>000 | Check | Check | Check |