lnPrinters = APRINTERS( This.Parent.aPrintArray ) FOR lnIdx = 1 TO lnPrinters *** Note below that you are adding a leading space. This *** prevents a network printer from appearing *** disabled in the combo due the leading "\" This.Parent.aPrintArray[ lnIdx, 1 ] = SPACE( 1 ) + ; This.Parent.aPrintArray[ lnIdx, 1 ] ENDFOR *** Make Sure we have some printers IF lnPrinters = 0 RETURN ENDIF This.Requery() For lnIdx = 1 TO lnPrinters IF UPPER(SET('PRINTER',2)) $ UPPER( This.Parent.aPrintArray[ lnIdx, 1 ] ) This.Value = This.Parent.aPrintArray[ lnIdx, 1 ] EXIT Endif ENDFOR *** Make sure we actually have a valid printer IF NOT EMPTY( This.Value ) TRY SET PRINTER TO NAME ( ALLTRIM( This.Value ) ) CATCH ENDTRY ENDIFYou also need to put the code that sets the printer in the Valid of the drop down list.
LOCAL lcCaption, lcCmd WITH This IF .FormCount = 1 .ShowToolbar() ENDIF .oToolBar.cmdPrint.Enabled = .T. &&Enable Print lcCmd = [REPORT FORM ( .cReportForm ) ] + ALLTRIM( .cScope ) + [ PREVIEW WINDOW Form1] &lcCmd *** Get rid of the formset after running the report IF TYPE( [Thisformset.oToolBar] ) = [O] AND NOT ISNULL( Thisformset.oToolBar ) Thisformset.oToolBar.Release() ENDIF Thisformset.release() Thisformset.Hide() ENDWITHNow, in order to preview a report using your formset and custom toolbar, you use code like this:
*** Instantiate the correct form loPreviewForm = NEWOBJECT( [frsReportPreview], [stdReport.vcx] ) IF VARTYPE( loPreviewForm ) = [O] WITH loPreviewForm .Form1.Caption = .Form1.Caption + [ for My Spiffy Report ] .cReportForm = [SpiffyReport.frx] ENDWITH loPreviewForm.DoPreview() loPreviewForm = .NULL. ENDIF