Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can preview those SELECTED, but not Print those SELECTED
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01221933
Message ID:
01223457
Vues:
21
>Ok.. I fixed this by setting
>
>SET PRINTER TO DEFAULT
>
>to the beginning of the method.
>
>>How is that possible??????? I am so........... confused!! (Could it be the Tag fields in the report???)
>
>But I am still at a loss of why the report prints blank....

Ok, I finally got it fixed.............. here is the final code....
LOCAL lcRxCaption,lcPharmacy,lcPhone, llMarked, lcSetExact

SET PRINTER TO Default

*TMT Moved focus from grid to the txtDrugFilter object to avoid problems with the preview and print....
*In this case, if the grid has the focus, then the preview will show correctly, but not print anything....
Thisform.cntActions.txtDrugFilter.Enabled = .T.
Thisform.cntActions.txtDrugFilter.SetFocus

llMarked = .F.

STORE SET('EXACT') TO lcSetExact
SET EXACT OFF 

Thisform.mousepointer = 11
Thisform.m_Actions(2)
ThisForm.txtStatus.value = "Printing Patient Medical Reports..."

SELECT rx
GO TOP 
*

*Check to see IF we have any marked records.....
DO WHILE NOT EOF('rx')
	IF marked = .T.
		llMarked = .T.
		EXIT 
	ENDIF
	SKIP  
ENDDO 

IF llMarked
	*TMT Moved focus from grid to the txtDrugFilter object to avoid problems with the preview and print....
	*In this case, if the grid has the focus, then the preview will show correctly, but not print anything....
	Thisform.cntActions.txtDrugFilter.Enabled = .T.
	Thisform.cntActions.txtDrugFilter.Visible = .T.
	Thisform.cntActions.txtDrugFilter.SetFocus
	
	*TMT Save the Marked values to the table, so the SQL select can see these marked values.
	*We will reset them back to .F. later in the actual table.
	=TABLEUPDATE(.T.,.T.,'rx')

	*Now, select which SQL select to use, based on the index order... how we wish to see the data
	IF Thisform.p_OrderBy = 1	&& filldate
		SELECT * FROM rx, drug, doctor ;
			WHERE rx.drug_id = drug.drug_id  AND rx.doctor_id = doctor.doctor_id AND marked ;
			order BY filled_date DESC, rx_no DESC, refill_no DESC INTO CURSOR rxpmr
	ELSE						&& decendrx
		SELECT * FROM rx, drug, doctor ;
			WHERE rx.drug_id = drug.drug_id  AND rx.doctor_id = doctor.doctor_id AND marked ;
			order BY rx_no DESC, refill_no DESC INTO CURSOR rxpmr
	ENDIF
	
	REPORT FORM RxPMR NOCONSOLE TO PRINTER PREVIEW 
	USE IN rxpmr
	
	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 

SELECT rx
REPLACE ALL marked WITH .F.
=TABLEUPDATE(.T.,.T.,'rx')

*TMT Moved focus back to the grid to refresh the grid.....
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)
So, I had to resort to an SQL statement to get the data from the underlying tables what were "marked" (not until I saved the data with Tableupdate). This SQL statement fed the report. Then I cleared the "marked" records in the underlying table (leaving them "marked" on the grid when it was refreshed).

And yes, I had to set focus OFF of the grid for it to work. What a pain!!! Never saw this "problem" in all the years I've worked with VFP.

Now, on to the next change... err.. bug.

Thanks everyone!
Tommy Tillman A+ NetWork+ MCP
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform