FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Total a Column in xBrowse with ADO
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Total a Column in xBrowse with ADO
Posted: Wed Jan 08, 2014 10:27 PM
To All

I have searched the forum and samples and can not find a syntax that works to total a specific column ( 6 ) in xBrowse. Here is my code... as you can see from the rem outs, I am struggling.

The function _BrowColor(oLbxB) just colors the rows .. and I will fix the text on the buttons :-) Any advise is welcome.

Rick Lipkin
Fwh 12.03
Code (fw): Select all Collapse
 REDEFINE xBROWSE oLbxB      ;
         RECORDSET oRsBill           ;
         COLUMNS "BILLDATE",         ;
                 "INVOICENUMBER",    ;
                 "PUBLICATIONNAME",  ;
                 "DESCRIPTION",      ;
                 "AMOUNTDUE",        ;
                 "BALANCE",          ;
                 "BILLS"             ;
         COLSIZES 72,57,125,145,65,65,35  ;
         HEADERS "BillDt",           ;
                 "InvNumb",          ;
                 "Publication",      ;
                 "Description",      ;
                 "AmtBilled",        ;
                 "Balance",          ;
                 "Bills"             ;
         ID 372 of oFld:aDialogs[2]  ;
         AUTOCOLS FOOTERS LINES CELL

         oLbxB:nMarqueeStyle := MARQSTYLE_HIGHLROW
         oLbxB:lRecordSelector := .f.
         oLbxB:lHScroll := .f. // turn off horiz scroll bar

         oCol := oLbxB:aCols[ 1 ]
         oCol:bStrData := { |x| x := if(oRsBill:eof, ,TtoDate(oRsBill:Fields("BillDate"):Value)),;
                                     If( Empty(x), ctod(""),x ) }
         oLbxB:aCols[1]:nDataStrAlign := AL_LEFT
         oLbxB:aCols[1]:nHeadStrAlign := AL_LEFT

         oLbxB:aCols[6]:lTotal := .t.
         oLbxB:aCols[6]:nTotal := 0 // this line also is required

         /*
         If !Empty( oCol := oLbxB:oCol( "Balance" ) )
            oCol:nTotal    := 0
            oCol:lTotal   := .t.
         Endif
         */
         oLbxB:MakeTotals()

         _BrowColor(oLbxB)

         oLbxB:bLDblClick := { |nRow,nCol | _BillView( "V",oRsBill,oFontB,oBtn0,oBtn1,;
                                                           oBtn2,oBtn3,oBtn4,oBtn13 ),oLbxB:SetFocus() }

Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Total a Column in xBrowse with ADO
Posted: Thu Jan 09, 2014 12:04 AM

Rick
Maybe this thread will help serve

viewtopic.php?f=3t=27307p=151848hilit=maketotals#p151848

&&&

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Total a Column in xBrowse with ADO
Posted: Thu Jan 09, 2014 01:39 PM
Cristobal

Thank you for your reply .. unfortunately re-arranging the code like this had no effect. The Column total still says 0.00. I am just curious if having this browse in a Folder has anything to do with it. This code is associated with the second folder ?

Rick Lipkin

Code (fw): Select all Collapse
 REDEFINE xBROWSE oLbxB      ;
         RECORDSET oRsBill           ;
         COLUMNS "BILLDATE",         ;
                 "INVOICENUMBER",    ;
                 "PUBLICATIONNAME",  ;
                 "DESCRIPTION",      ;
                 "AMOUNTDUE",        ;
                 "BALANCE",          ;
                 "BILLS"             ;
         COLSIZES 69,51,110,145,65,65,35  ;
         HEADERS "BillDt",           ;
                 "InvNumb",          ;
                 "Publication",      ;
                 "Description",      ;
                 "AmtBilled",        ;
                 "Balance",          ;
                 "Bills"             ;
         ID 372 of oFld:aDialogs[2]  ;
         AUTOCOLS FOOTERS LINES CELL

         WITH OBJECT oLbxB
            :Balance:nFooterType  := AGGR_SUM
            :MakeTotals()
          END


         oLbxB:nMarqueeStyle := MARQSTYLE_HIGHLROW
         oLbxB:lRecordSelector := .f.
         oLbxB:lHScroll := .f. // turn off horiz scroll bar

         oCol := oLbxB:aCols[ 1 ]
         oCol:bStrData := { |x| x := if(oRsBill:eof, ,TtoDate(oRsBill:Fields("BillDate"):Value)),;
                                     If( Empty(x), ctod(""),x ) }
         oLbxB:aCols[1]:nDataStrAlign := AL_LEFT
         oLbxB:aCols[1]:nHeadStrAlign := AL_LEFT
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Total a Column in xBrowse with ADO
Posted: Fri Jan 10, 2014 02:22 PM

Rick
Have you tried to put the MakeTotals () in the corresponding dialog on init?

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Total a Column in xBrowse with ADO
Posted: Fri Jan 10, 2014 02:33 PM
Cristobal

Thank you for your suggestion .. taking your hint it appears I have solved the problem by putting the :MakeTotals() in the FolderEx statement. As you click on ( change ) the tabs, it seemed the right place to insert the code like this :

Code (fw): Select all Collapse
 REDEFINE FOLDEREX oFld ID 173 of oGrps ;
                PROMPT "Advertising Information", "Billing-Invoicing Information";
                DIALOGS "ADVTBROW", "BILLBROW" ;
                ON CHANGE( (nFolder := nOption ,;
                          If( nFolder = 1, oLbxA:SetFocus(), ),;
                          If( nFolder = 2, (oLbxB:MakeTotals(),oLbxB:SetFocus()), )) ) // MakeTotals() here


I now get the total I am looking for. Many thanks for your suggestion!

Rick Lipkin
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Total a Column in xBrowse with ADO
Posted: Fri Jan 10, 2014 02:36 PM

What matters is that you've solved
The Maketotals () I always get after the CreateFromCode or on init, or on change as you, although occasionally still gives me some headache

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces

Continue the discussion