LOCAL lcRxCaption,lcPharmacy,lcPhone, llMarked, lcSetExact Thisform.cntActions.txtDrugFilter.Enabled = .T. Thisform.cntActions.txtDrugFilter.SetFocus llMarked = .F. *TMT This code below is from the lblOrderBy click method... modified slightly to not show the messagebox in it... STORE SET('EXACT') TO lcSetExact SET EXACT OFF Thisform.mousepointer = 11 Thisform.m_Actions(2) ThisForm.txtStatus.value = "Printing Patient Medical Reports..." SELECT rx *TMT 05/04/2007 Added to set the environment so that the report will see the rx table correctly and be *able to print the marked records... *!* IF Thisform.p_OrderBy = 1 *!* SET ORDER TO filldate IN rx *!* ELSE *!* SET ORDER TO decendrx IN rx *!* ENDIF *!* SET KEY TO (STR(Thisform.p_patient_id)) GO TOP * *Count the number of marked records in this filter range DO WHILE NOT EOF('rx') IF marked = .T. llMarked = .T. EXIT ENDIF SKIP ENDDO IF llMarked SELECT rx Thisform.cntActions.txtDrugFilter.Enabled = .T. Thisform.cntActions.txtDrugFilter.Visible = .T. Thisform.cntActions.txtDrugFilter.SetFocus REPORT FORM RxPMR FOR marked = .T. NOCONSOLE TO PRINTER PREVIEW Thisform.cntActions.txtDrugFilter.Enabled = .F. Thisform.grdProfile.SetFocus ELSE MESSAGEBOX("There are no Rx's selected to print the Patient Medical Report" + CHR(13) + ; "(To select a Rx, check it)",64,"Cannot Print PMR(s)") ENDIF Thisform.cntActions.txtDrugFilter.Enabled = .F. Thisform.grdProfile.SetFocus Thisform.mousepointer = 0 ThisForm.txtStatus.value = "" IF Thisform.p_OrderBy = 1 SET ORDER TO filldate IN rx ELSE SET ORDER TO decendrx IN rx ENDIF SELECT rx SET KEY TO (STR(Thisform.p_patient_id)) IF Thisform.p_viewtype = 1 SELECT refill SET FILTER TO INLIST(status,0,1,4,5) && 4 Included so batch Rx's cant be refilled SET EXACT OFF lcFilter = IIF(NOT EMPTY(Thisform.p_buffer),; Thisform.p_previousdrugfilter + " AND UPPER(drug.name) = '" + ; ALLTRIM(UPPER(Thisform.p_buffer)) + "' IN Rx",; Thisform.p_previousdrugfilter + " IN Rx") SELECT Rx SET FILTER TO &lcFilter GO TOP IN rx ELSE SELECT refill SET FILTER TO SELECT rx SET EXACT OFF lcFilter = IIF(NOT EMPTY(Thisform.p_buffer),; "UPPER(drug.name) = '" + ; ALLTRIM(UPPER(Thisform.p_buffer)) + "' IN Rx","") SELECT Rx SET FILTER TO &lcFilter GO TOP IN rx ENDIF *Thisform.grdProfile.refresh() Thisform.m_UpdateStaticArea() Thisform.MousePointer = 0 SET EXACT &lcSetExact ThisForm.grdProfile.Refresh() Thisform.m_Actions(1)The Report itself does not have a Data Environment.