Page 1 of 1

where to place gotop() in xbrowse

Posted: Thu Mar 01, 2007 4:29 pm
by Ehab Samir Aziz
Where should I place xBrw:gotop() inside xbrowse . That code below is not causing the xbrowse to go top xBrw:pageup() is working but not my demand .

Code: Select all

STATIC FUNCTION listmete( oWnd ) 
*-------------------------- 

local oDlg, oCol 
local nTotal:=0 

local oBrw 
local nfor,cFilter:="",bFilter:="" 
local y 
local V_me_mc_serl:= space(7) 

REQUEST ADS 
rddRegister( "ADS", 1 ) 
rddsetdefault( "ADS" ) 
AdsSetDeleted(.T.) 
SET SERVER LOCAL 
SET FILETYPE TO CDX 


select 4 
use mete 
index on mete->ME_mc_serl to mete 
index on str(mete->year) + str(mete->month) to mete1 
index on mete->me_date to mete2 
set index to mete 


if MsgGet( "Serial Machine", "Enter Serial Machine", @V_me_mc_serl,; 
              "..\lupa.bmp" ) 
      select 3 
      use mach 
      set index to mach5 
      *MSGINFO(IndexKey()) 
      if ! DbSeek( (V_me_mc_serl )) 
         MsgAlert( "I don't find that serial" ) 
      endif 
   endif 



y := "'"+padr(V_me_mc_serl,7)+"'" 
cFilter := "me_mc_serl = "+ y 
bFilter = "{||"+cFilter+"}" 



select 4 
use mete 
DBSETFILTER(&bFilter,cFilter) 
mete->(DBGOTOP()) 

   DEFINE DIALOG oDlg of oWnd FROM 0,0 TO 45,128 TITLE "Meter reads browse " 

   oBrw := TXBrowse():New( oDlg ) 
   oBrw:nMarqueeStyle       := MARQSTYLE_HIGHLCELL 
   oBrw:nColDividerStyle    := LINESTYLE_BLACK 
   oBrw:nRowDividerStyle    := LINESTYLE_BLACK 
   oBrw:lColDividerComplete := .t. 
   oBrw:nHeaderLines        := 1 
   oBrw:nFooterLines        := 1 
   oBrw:nDataLines          := 1 
   oBrw:lFooter             := .t. 
   oBrw:SetRDD() 
   oBrw:CreateFromCode() 
   oBrw:nTop = 0 
   oBrw:nLeft = 0 
   oBrw:nWidth = 1000 
   oBrw:nHeight =600 



   for nFor := 1 to Fcount() 

*oBrw:aCols[ nFor ]:cFooter       := alltrim(STR(TOTALEM2(V_me_mc_serl),12,0)) 

   if nFor=27 
      oBrw:aCols[ nFor ]:cHeader       := FieldName( nFor ) 
      oBrw:aCols[ nFor ]:cFooter       := alltrim(STR(TOTALEM2(),12,2)) 
      loop 
   endif 

      *oBrw:aCols[ nFor ]:cHeader       := FieldName( nFor ) 
      *oBrw:aCols[ nFor ]:cFooter       := FieldName( nFor ) 
   next 

    
   oBrw:Refresh(.t.)            // Repaint the ListBox 





ACTIVATE DIALOG oDlg ON INIT (oBrw:SetSize( 1000, 600 ),BuildButtons( oDlg ),oBrw:gotop(),oBrw:Refresh(.t.),oDlg:Refresh(.t.)) 

RETURN NIL

Posted: Thu Mar 01, 2007 5:26 pm
by James Bott
Ehab,

Here are some things to try.

You shouldn't use the alias name in indexes.

I see that you are opening two files and not specifying the alias in the browse definition. Try adding this:

oBrw:cAlias:="mete"

Also, it appears that you open mete, index it, then reopen it (causing the indexes to be closed) and you don't reopen the indexes.

I don't know why you would even need to issue a oBrw:gotop() since the database should already be there. I would try checking right after this code:

select 4
use mete
DBSETFILTER(&bFilter,cFilter)
mete->(DBGOTOP())

msgInfo( [put field name here] )

If you are not at the top record here, then it has nothing to do with the browse.

James

Posted: Thu Mar 01, 2007 5:27 pm
by Antonio Linares
Ehab,

Please understand what means a small and self contained sample to test.

We don't have your DBFs, and we can not build your portion of code. In order to provide tech support, you have to provide a small and self contained sample that reproduces the error to fix. Thanks,