Navigation:  Reference > Commands >

If Duplicate Record

Print this Topic Previous pageReturn to chapter overviewNext page

 

This is a process control command, i.e., it will control whether a command, or group of commands, will be executed.  This is one part of a complete command structure.

 

IFDUP sac Required - This is the key name.  The program checks the file to see if a record exists with the current (active) value in the key field(s).  If it does, the what_to_do action will be taken.  If it does not and the what_to_do action is not THEN, the program will look for the next ELSE_IF or ELSE command.  If one is not found, the program will transfer control to the line following the appropriate ENDIF command.

 

what_to_do - sac The action to take if a record is found with the specified key value.  Possible actions include:

 

       DO -  Do the following commands until the program reaches an ELSE, ELSE_IF or ENDIF command.  This is the default value and doesn't have to be specified.

 

       THEN -  Execute the following command.  The command to execute in this case may follow on the same physical line or it will execute the command on the following line.

 

       GOTO -  Goto the line label specified in the goto_gosub_label.

 

       GOSUB - Gosub the line label specified in the goto_gosub_label.

 

       RET - Execute the RET (Return) command.

 

       NOTE:  DO NOT use this option to return a value.  The RET here is just a return.  If you want to return a value you would use:

 

                               IFDUP sac THEN RET value

 

goto_gosub_labelIf the what_to_do option is GOTO or GOSUB then you must specify the label name here.

 

COMMENTS

Please note that the IFDUP command cannot tell if the duplicate record is active.  Therefore you should not allow the user to re-enter (change) the relevant key field if the record is active.  For example, you might use the following code:

       

       EntryFieldObjectName.Pre:

         RET IFNA(file_handle)

 

For more information on the different structured programming commands, and the IF command in particular, please see Structured Programming Commands.

 

NOTE:  This command works with Btrieve files only.  If you are checking for duplicate records in CodeBase files, use the IFDUPCB() function.

 

NOTE: If you have two records with the same key value the first record is not considered a duplicate but he second record will be the dupe record.

 

Sample

 

ssn.post:

         ifdup bkpr.emp.ssn

          msg 'The SS# you have entered is already on file for another employee please check your entry.'

          ret .f.

        endif

        ret .t.

 

 

SEE ALSO

ELSE, ELSE_IF, ENDIF, IFNA(), ACTIVE()  (IFDUPECB() Codebase)

 

 


Page url: http://www.cassoftware.com/tas/manual/ifduplicaterecord.htm