I try the test xbgetbar.prg with My archive dbf
When I press set filter button it make error
sad there is not the dbf open ...why ?
- Code: Select all Expand view
- DataBases in use
================
1: TDF00001 RddName: DBFCDX
==============================
RecNo RecCount BOF EOF
1 7959 .F. .F.
Indexes in use TagName
CODICE COMCOD
=> UPPER(LOCALITA) COMLOC
UPPER(PROVINCIA) COMPRO
CAP COMCAP
image
https://ibb.co/fYW9Mm8
- Code: Select all Expand view
- Time from start: 0 hours 0 mins 29 secs
Error occurred at: 30-03-2019, 10:26:34
Error description: Error DBCMD/2001 Workarea not in use: DBSETFILTER
Stack Calls
===========
Called from: => DBSETFILTER( 0 )
Called from: source\ut\ut_codFisc.prg => SETFILTER( 834 )
Called from: source\ut\ut_codFisc.prg => (b)SELEZIONECOMUNI( 793 )
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:CLICK( 697 )
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:LBUTTONUP( 983 )
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1791 )
Called from: .\source\classes\BTNBMP.PRG => TBTNBMP:HANDLEEVENT( 2006 )
Called from: .\source\classes\WINDOW.PRG => _FWH( 3541 )
Called from: => DIALOGBOXINDIRECT( 0 )
probable because I use tdatabase and function SetFilter( oBrw ) is wrong
How I can to not use buttons on dialog ?
- Code: Select all Expand view
#include "FiveWin.ch"
#include "Report.ch"
#include "dtpicker.ch"
#include "xBrowse.ch"
static oComuni,oProvince,oStati
static cPathDb
REQUEST DBFCDX
FUNCTION Main()
* HB_LangSelect("IT")
* HB_SetCodePage("ITWIN")
SET _3DLOOK ON
SET CENTURY ON
SET DATE ITALIAN
RDDSetDefault( 'DBFCDX' )
cPathDb:="DB\"
oComuni:= TDatabase():Open( , cPathDb+"COMUNI", "DBFCDX", .T. )
oComuni:setorder(2)
oComuni:gotop()
SelezioneComuni(oComuni)
return nil
//-----------------------------------------------------------------------------//
Function SelezioneComuni(oComuni)
local oDlg, oBrw, oFont, oBold
local n
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-12
DEFINE FONT oBold NAME "TAHOMA" SIZE 0,-12 BOLD
DEFINE DIALOG oDlg SIZE 800,500 PIXEL TRUEPIXEL ;
FONT oFont TITLE FWVERSION + "Ricerca Comuni"
@ 110,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
DATASOURCE oComuni AUTOCOLS CELL LINES NOBORDER
oBrw:aCols[2]:uBarGetVal:= Space(60)
oBrw:aCols[3]:uBarGetVal:= Space(2)
oBrw:nGetBarHeight:=33
oBrw:lGetBar := .t.
WITH OBJECT oBrw
:nHeaderHeight := 40 // optional
:oHeaderFonts := oBold
:bClrEdits := { || { CLR_BLACK, CLR_YELLOW } }
:AutoFit()
//
:CreateFromCode()
END
@ 10,20 SAY "Gets under Headers. Entered values can be used" + ;
"for filtering or any othe purpose" + CRLF + ;
"Usage: oCol:uBarGetVal := Space( 10 ); oBrw:lGetBar := .t." ;
SIZE oDlg:nWidth - 40,40 PIXEL OF oDlg CENTER
@ 60, 20 BTNBMP PROMPT { || If( oBrw:lGetBar, "Nascondi", "Mostra" ) } ;
SIZE 100,40 PIXEL OF oDlg FLAT ;
ACTION ( oBrw:lGetBar := ! oBrw:lGetBar, oBrw:Refresh() )
@ 60,140 BTNBMP PROMPT "Ricerca" ;
SIZE 100,40 PIXEL OF oDlg FLAT ;
ACTION ( oBrw:cAlias )->( SetFilter( oBrw ) )
@ 60,250 BTNBMP PROMPT "Pulisci" ;
SIZE 100,40 PIXEL OF oDlg FLAT ;
ACTION ( oBrw:cAlias )->( DBCLEARFILTER(), oBrw:Refresh(), oBrw:SetFocus() )
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont, oBold
return nil
//-----------------------------------------------------------------------//
static function SetFilter( oBrw)
local cFilter := ""
local n, oCol, uVal, cType
for n := 1 to Len( oBrw:aCols )
oCol := oBrw:aCols[ n ]
if ! Empty( uVal := oCol:uBarGetVal )
if !Empty( cFilter )
cFilter += " .AND. "
endif
cType := ValType( uVal )
do case
case cType == 'C'
uVal := Upper( AllTrim( uVal ) )
cFilter += '"' + uVal + '" $ UPPER( ' + FieldName( n ) + " )"
otherwise
cFilter += FieldName( n ) + " == " + cValToChar( uVal )
endcase
endif
next
if Empty( cFilter )
if ! Empty( DBFILTER() )
DBCLEARFILTER()
oBrw:Refresh()
endif
else
if !( DBFILTER() == cFilter )
SET FILTER TO &cFilter
GO TOP
oBrw:Refresh()
endif
endif
oBrw:SetFocus()
return nil
//----------------------------------------------------------------------------//