Page 1 of 1

Problem With searching customer Initial letter

Posted: Wed Dec 07, 2016 10:39 pm
by Silvio.Falconi
I wish the final user when click on tab th eproedure must show only the customer have the first letter as the oTab prompt
the test run but sometimes not run ok

Perhaps there is a another method ?

the code

Code: Select all

 
#include "FiveWin.Ch"
#include "ord.ch"
#include "xbrowse.ch"

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

REQUEST DBFCDX

static cFwhPath   := "c:\\work\\fwh\\"

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

function Main()
lOCAL oDlg,oTab,oFont
Local nOrder:= 1
local cPath    := cFwhPath + "samples\\"


   USE ( cPath + "CUSTOMER" ) NEW ALIAS CU SHARED
   INDEX ON FIRST TAG FIRST TO CTMP MEMORY

DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
 DEFINE DIALOG oDlg SIZE 620,700 PIXEL FONT oFont ;
      TITLE "Test telephon list"


  @ 10,20 XBROWSE oBrw OF oDlg SIZE -10,-70 PIXEL ;
      COLUMNS "First", "State", "Age", "HireDate", "Salary" ;
      ALIAS 'CUST' NOBORDER

   oBrw:lRecordSelector := .f.
   oBrw:nMarqueeStyle   := MARQSTYLE_HIGHLWIN7

   oBrw:CreateFromCode()


   @ 280, 3 TABS oTab ;
      OPTION nOrder SIZE oBrw:nWidth()-80, 12 PIXEL OF oDlg ;
      ITEMS "All","A","B","C","D","E","F","G","H","I","L","M","N","O","P","Q","R","S","T","U","V","Z";
      ACTION CuFiltrar(oBrw,oTab,oTab:nOption,nOrder)




 ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil




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

init procedure PrgInit

   SET DATE ITALIAN
   SET CENTURY ON
   SET TIME FORMAT TO "HH:MM:SS"
   SET EPOCH TO YEAR(DATE())-50

   SET DELETED ON
   SET EXCLUSIVE OFF

   RDDSETDEFAULT( "DBFCDX" )

   XbrNumFormat( 'E', .t. )
   SetKinetic( .f. )
   SetGetColorFocus()
   SetBalloon( .t. )

return
//-----------------------------------------------------------------------------------//
Function CuFiltrar(oGrid,oTab,n,nOrder)
     msginfo(n)
if n=1
CU->(DbClearFilter())
CU->(DbGoTop())
oGrid:Refresh(.t.)
return nil
endif

do case
case nOrder= 1
set filter to left(CU->FIRST,1)=oTab:aPrompts[n]
case nOrder= 2
set filter to left(CU->FIRST,1)=oTab:aPrompts[n]
endcase
CU->(DbGoTop())
oGrid:Refresh(.t.)
return ni

Re: Problem With searching customer Initial letter

Posted: Thu Dec 08, 2016 3:18 pm
by dbmanfwh
slivio,
Try to

Code: Select all

Function CuFiltrar(oGrid,oTab,n ) // ,nOrder)

if n=1
   CU->(DbClearFilter())
else
   set filter to left(CU->FIRST,1)=oTab:aPrompts[n]
endif

CU->(DbGoTop())
oGrid:Refresh(.t.)

return nil