Navigation:  Reference > Functions >

IfDupRecordInCodeBaseFile()

Print this Topic Previous pageReturn to chapter overviewNext page

 

IFDUPCB(1,2)

 

PURPOSE

This function will check for duplicate records in an existing database depending on the data entered for the record.  The check does not effect the values in the current record.

 

PARTS

 

1 f/c/eRequired - File handle.

 

2 f/c/eRequired - Key name to check.  This must be a legitimate key name in the FD for the file.

 

RETURN TYPE - L

If there is an existing record with the same value for that key the function will return True, otherwise False

 

COMMENTS

This function not only checks for an existing record with the same index value, it also checks to make sure that it doesn't find the same record.  So, you don't have to worry about checking for an active record if this function returns True.

 

NOTE:  This function works only for CodeBase type files.  For Btrieve files use the IFDUP command.

 

NOTE: This funtion will not work if you have not used the openv command with dupecheck see docs for openv command for details.

 

EXAMPLE

//in the OpenFiles section a file is customer file is opened

//don't forget the DupCheck option.

define cust_hndl type i

openv 'bkarcust' ext 'c' fnum cust_hndl

...

 

//in another routine you would place the duplicate check routine

//to make sure the user didn't try to create multiple records

//with the same customer code.  You can also use the Duplicates

//option when defining the FD for the file.  This, however, might

//give you a little more control over what happens and the FD test

//occurs only at the save.

 

if IfDupCB(cust_hndl,'bkar.custcode')

msg 'You have tried to enter a duplicate customer...'

set_focus 'custcode' //back to the customer code object

ret

endif

 

 

 


Page url: http://www.cassoftware.com/tas/manual/ifduprecordincodebasefile().htm