AnsweredAssumed Answered

In browse mode, if a duplicate record, do not record duplicate and go to original record

Question asked by miw on Nov 12, 2010
Latest reply on Nov 12, 2010 by RickWhitelaw

Title

In browse mode, if a duplicate record, do not record duplicate and go to original record

Post

I am trying to create script whereby when entering records, if a duplicate input arises, I can direct the script not to record the duplicate entry and then be pointed to the original record (somewhat similar to the post at Avoiding Duplicate Records on Entering, where I have posted this question as an add-on comment - I thought I would repost my question separately since I do not know if anyone reviews any follow-on comments after a solution has been found for another, albeit somewhat similar problem).  So I have a FirstName field (Validate - not empty) and LastName field (Validate - not empty). On the layout I enter the FirstName first (on exit, I only commit the record), then the LastName (on exit, I run the script below to check for FullName being unique).  I have a FullName field that is auto-calculated and concatenates as follows:  Names::LastName & ", " & Names:FirstName.  The FullName field is setup to be always validated and to be unique.  I want my script to search for a duplicate FullName only after I enter data in the LastName field at which point my script would execute.  If the FullName is not a duplicate, I want to accept the new record, if the FullName is a duplicate, I want only one result:  delete the duplicate record I just created and take me to the original record of the FullName concatenation.  Here is my script:

Set Error Capture [On]

Commit Records/Requests [No dialog]

If [Get (LastError) = 0

Show Custom Dialog ["Duplicate Record Error!"; "This combination of Last and First Name already exists.  Duplication is not allowed.  Click below to go to the original record.": Buttons:  GotoOriginal (default)

If [Get (LastMessageChoice) = 1]

Set Variable [$DupeNAme; Value:Names::FullName]

Commit Records/Requests [No dialog]

Delete Record/Request [No dialog]

Enter find Mode []

Set Field [Names::FullName; $DupeName]

Perform Find []

End if

End if

My main problem is that everytime I try to add a record,  I get my error message that the FullName field is not unique (even when I have no existing records in the file)!  Anticipating that I get this fixed, how can I get my perform find accomplished (bringing up on my layout the original FullName record), but showing all records and exiting the find script (such that I am on my layout, looking at all records but on the Original FullName record and not having script remaining to execute or needing to cancel the find executed by the script)?

 

 

Outcomes