Search on customer.dbf
Posted: Mon Apr 13, 2020 5:06 pm
using customer.dbf, when inserting a record, I should check if the surname (First field) and the name (Last) exist
so you can check records for the same surnames (First)
sample I have
the function only runs well for one field, how can I also check the other one so that I can check the same surnames (but with different names)
example :
Falconi Silvio
Falconi Max
Falconi Paolo
I tried also to make an index on Upper(first)+Upper(last)
so you can check records for the same surnames (First)
sample I have
Code: Select all
@ 12, 10 SAY "First :" OF oDlg SIZE 33, 8 PIXEL
@ 10, 49 GET aGet[1] VAR cFirst OF oDlg UPDATE SIZE 100, 12 PIXEL ;
VALID Custvalid( cFirst, aGet[1], nMode)
@ 26, 10 SAY "Last :" OF oDlg SIZE 22, 8 PIXEL
@ 24, 49 GET aGet[2] VAR cLast OF oDlg UPDATE SIZE 100, 12 PIXEL ;
VALID Custvalid( cLast, aGet[2], nMode)
function Custvalid( cCliente, oGet, nMode)
local lReturn := .f.
local nRecno := CU->( RecNo() )
local nOrder := CU->( OrdNumber() )
local nArea := Select()
//if is empty
if Empty( cCliente )
if nMode == 4 .OR. nTag == 2
RETURN .t.
else
MsgStop("this field cannot be empty.")
RETURN .f.
endif
endif
SELECT CL
CL->( DbSetOrder( nTag ) )
CL->( DbGoTop() )
if CL->( DbSeek( UPPER( cCliente ) ) )
DO CASE
Case nMode == 1 .OR. nMode == 3
lReturn := .f.
MsgStop("Existing customer.")
Case nMode == 2
if CL->( Recno() ) == nRecno
lReturn := .t.
else
lReturn := .f.
MsgStop("Existing customer.")
endif
Case nMode == 4
lReturn := .t.
END CASE
else
MsgStop("customer not found")
lReturn := .f.
endif
endif
endif
if lReturn == .f.
oGet:cText(space(15)
else
oGet:cText( cCliente )
endif
CL->( DbSetOrder( nOrder ) )
CL->( DbGoTo( nRecno ) )
Select (nArea)
the function only runs well for one field, how can I also check the other one so that I can check the same surnames (but with different names)
example :
Falconi Silvio
Falconi Max
Falconi Paolo
I tried also to make an index on Upper(first)+Upper(last)