nageswaragunupudi wrote:Mr. Silvio
Without any special index:
local oDbf
local cName := "David"
local cLast := "Jochum"
oDbf := TDataBase():Open( nil, "CUSTOMER", "DBFCDX", .t. )
if oDbf:LookUp( UPPER( PADR( cName, 20 ) + PADR( cLast, 20 ) ), ;
"UPPER(FIRST+LAST)", { || FOUND() } )
? "Found"
else
? "Not Found"
endif
oDbf:Close()
Note: 20 and 20 in PADR() function are the field sizes of FIRST and LAST.
Sorry Nages I have a bit of everything. your idea can only work that I have to manage the various insertion modes
nMode = 1 new
nMode = 2 change
nMode = 3 duplicate records
nMode = 4 I need this in the selection dialog
I made
@ 12, 10 SAY "Cognome:" OF oDlg SIZE 31, 8 PIXEL FONT oFont
@ 10, 67 GET aGet[1] VAR oCliente:Clicognome OF oDlg SIZE 100, 12 PIXEL FONT oFont
@ 26, 10 SAY "Nome :" OF oDlg SIZE 22, 8 PIXEL FONT oFont
@ 24, 67 GET aGet[2] VAR oCliente:Clinome OF oDlg SIZE 100, 12 PIXEL FONT oFont ;
VALID SearchCli( oCliente:Clicognome, aGet[2], 1,oDbf,oCliente:Clinome )
function SearchCli ( cCognome, oGet, nMode,oDbf,cNome )
local lreturn := .f.
local nRecno := oDbf:RecNo()
local nOrder := oDbf:OrdNumber()
local nArea := Select()
if Empty( cNome )
if nMode == 4
return .t.
else
MsgStop("E' obbligatorio questo campo.")
return .f.
endif
endif
oDbf:SetOrder( 1 ) //CLICOGNOME
oDbf:GoTop()
IF oDbf:LookUp( UPPER( PADR( cCognome, 20 ) + PADR( cNome, 20 ) ), ;
"UPPER(CLICOGNOME+CLINOME)", { || FOUND() } )
DO CASE
Case nMode == 1 .OR. nMode == 3 // new or duplicate
lreturn := .f.
MsgStop("Nominativo esistente.")
Case nMode == 2 // modify
if oDbf:Recno() == nRecno
lreturn := .t.
else
lreturn := .f.
MsgStop("Nominativo esistente.")
endif
Case nMode == 4 //selection dialog
lreturn := .t.
END CASE
ELSE
if nMode < 4
lreturn := .t.
else
if MsgYesNo("Nominativo inesistente. ¿ Desideri inserirlo ora? ") // on selection dialog ask to add the new record
lreturn := ClEdita( , 1, , , @cCognome )
else
lreturn := .f.
endif
endif
endif
if lreturn == .f.
oGet:cText( space(20) )
endif
oDbf:SetOrder( nOrder )
oDbf:GoTo( nRecno )
Select (nArea)
return lreturn
First I insert "Vitali" "Pietro" and the procedure returns me that it found it in the archive,
deletes the contents of the get (aGet [2]) and points the cursor on the get of the name field. all ok
Then I insert "silvio" instead of "Pietro" and the procedure makes an error in line 777 which appears to be
this is the error
Application
===========
Path and name: C:\Work\Prg\Prenotazioni\WinBeach.Exe (32 bits)
Size: 7,603,200 bytes
Compiler version: Harbour 3.2.0dev (r1904111533)
FiveWin version: FWH 21.04
C compiler version: Borland/Embarcadero C++ 7.0 (32-bit)
Windows version: 6.1, Build 7601 Service Pack 1
Time from start: 0 hours 0 mins 29 secs
Error occurred at: 14-06-2021, 23:29:13
Error description: Error BASE/1066 Parametro errato: condizionale
Args:
[ 1] = U
Stack Calls
===========
Called from: source\Clienti\PClienti.prg => CLCLAVE( 777 )
Called from: source\Clienti\PClienti.prg => (b)CLEDITA( 597 )
Called from: .\source\classes\TGET.PRG => TGET:LVALID( 2282 )
Called from: .\source\classes\CONTROL.PRG => TGET:FWLOSTFOCUS( 1205 )
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1802 )
Called from: .\source\classes\TGET.PRG => TGET:HANDLEEVENT( 1279 )
Called from: .\source\classes\WINDOW.PRG => _FWH( 3560 )
Called from: => DIALOGBOXINDIRECT( 0 )
Also If I make
IF oDbf:LookUp( UPPER( PADR( cCognome, 20 ) + PADR( cNome, 20 ) ), ;
"UPPER(CLICOGNOME+CLINOME)", { || FOUND() } )
lreturn := .f.
else
lreturn := .t.
endif
give me the same error on the second time when I insert a Last new
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com