FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour xBrowse report oLbx:Report
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
xBrowse report oLbx:Report
Posted: Fri Jul 13, 2018 05:26 PM

To All

Is it possible to select ONLY the fields you wish xBrowse report to Print and also get a total number of records ?

Thanks
Rick Lipkin

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse report oLbx:Report
Posted: Sat Jul 14, 2018 05:54 AM
The only way is to hide the unwanted columns and call :Report().
This also means that Report() method prints what we see in the browse by default.
Total records printed is oBrw:nLen.

By using the 4th parameter bSetup, you get the full flexibility to define your own columns.
Example:
Code (fw): Select all Collapse
#include "fivewin.ch"
#include "report.ch"

function Main()

   local oDlg, oBrw, oCn, oRs

   oCn   := FW_OpenAdoConnection( "xbrtest.mdb" )
   oRs   := FW_OpenRecordSet( oCn, "customer" )

   DEFINE DIALOG oDlg SIZE 500,300 PIXEL TRUEPIXEL

   @ 60,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oRs COLUMNS "First", "City", "Age" ;
      CELL LINES NOBORDER

   oBrw:CreateFromCode()

   @ 20,20 BUTTON "REPORT" SIZE 80,30 PIXEL OF oDlg ;
      ACTION oBrw:Report( nil, nil, nil, { |oRep,brw| MyReportSetup( oRep, brw ) } )

   ACTIVATE DIALOG oDlg CENTERED

   oRs:Close()
   oCn:Close()

return nil

//----------------------------------------------------------------------------//

function MyReportSetup( oRep, oBrw )

   local oRs   := oBrw:oRs
   local cLines   := cValToChar( oBrw:nLen ) + " lines"

   COLUMN TITLE "First Name" DATA oRs:Fields( "First" ):Value SIZE 25
   COLUMN TITLE "Street"     DATA oRs:Fields( "Street" ):Value SIZE 25
   COLUMN TITLE "City"       DATA oBrw:City:Value SIZE 25
   COLUMN TITLE "Salary"     DATA oRs:Fields( "salary" ):Value PICTURE "999,999.99" TOTAL

   oRep:bPostEnd   := { || oRep:Say( 1, cLines ) }

return .t.

// return .t. means xbrowse should not add columns
//----------------------------------------------------------------------------//


The report has some columns that are not even seen in the xbrowse and some columns are used from the browse.
Regards



G. N. Rao.

Hyderabad, India
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: xBrowse report oLbx:Report
Posted: Sat Jul 14, 2018 01:21 PM
Rao

I am using FWH 1707 and your example errors during the compile at:
Code (fw): Select all Collapse
 COLUMN TITLE "First Name" DATA oRs:Fields( "First" ):Value SIZE 25


"Syntax error at Title" ... is this because I am using an older version of FWH ? and is there a work around ?

Thanks
Rick Lipkin

ps .. just curious about what are the first three parameters .. I will have a look at my xBrowse.Prg .. again, perhaps my FWH is just too old?
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse report oLbx:Report
Posted: Sat Jul 14, 2018 01:24 PM
This works in all versions.

Need to include "report.ch" also.

Parameters
Code (fw): Select all Collapse
METHOD Report( cTitle, lPreview, lModal, bSetUp, aGroupBy, cPDF )
Regards



G. N. Rao.

Hyderabad, India
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: xBrowse report oLbx:Report
Posted: Sat Jul 14, 2018 01:31 PM
Rao

Thanks .. that worked ... how do you apply

Code (fw): Select all Collapse
 oBrw:nLen


to show up at the bottom of the report to sum the number of records ?

Rick Lipkin
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse report oLbx:Report
Posted: Sat Jul 14, 2018 02:29 PM

Please see my modification.

Regards



G. N. Rao.

Hyderabad, India
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: xBrowse report oLbx:Report
Posted: Sat Jul 14, 2018 02:38 PM

Rao

As always ... Thank you!

Rick Lipkin

Continue the discussion