Newbies ppeffgra Posted August 24, 2001 Newbies Posted August 24, 2001 I am very new to scripting and I tried to get this question answered before, but I don't think I worded it right. Here goes, I have 6 text fields that a user enters data into. The user then pushes a button and this sets off a script that takes parts of this data and concatenates a new unique name that is then entered into another field. What I am trying to do is to take this new unique field name and have it compared to the unique field name in other records in the database. Im basically looking for duplicates so if there is a duplicate, I want the user to be immediately warned of this and prevented from using this already existing name. I know I can have some form of validation using the options under "Define Fields" but I need the validation to happen in a script. The script has some functions built into that lock the data so it cannot be changed later. If I use validation from Define Fields it halts the script, which I am trying to avoid. I know you can do a find to search for an exact match but I do not know how to integrate this into the script. How do I get FM to compare the current unique name field to the fields in existing records and have it respond if a match is found. Like I said before Im really new to this (I've only been using the program for about a week) so any help would be greatly appreciated. Many thanks!
mfrost Posted August 31, 2001 Posted August 31, 2001 You might get the solution even w/out scripting. First of all, create a self relationship. That means you create a relationship like this: name_dbase1::name_field1=name_dbase1::name_field1, so both key fields are the same. Then create a calculated field which shows the number of fields. If the number > 1 you can show an alert or do sth else. Hope it will work. Matthias
Fuper Posted September 2, 2001 Posted September 2, 2001 What Matthias has described is, that you create a relationship of the name field back to itself. A calc field can then be defined to equal the count of that field. Place this on a layout and see what happens when there is more than one record with a certain name--See? Your script can check for this condition. Alternately, another calc field can be defined to show an error message on the screen as soon as the count field shows that a duplicate exists -- no script required. You had a problem with validation failures interrupting your script, but this is what 'error capture' is for. Turn it on within a script, and no error from that point on will even cause an alert. At the point where the validation problem occurs, use an If statement to check whether Status (CurrentError) is from 500 to 509 (the codes for failed validations -- see FM Help). If no error, this function returns a zero. But don't underestimate the value of Matthias' solution.
Newbies ppeffgra Posted September 4, 2001 Author Newbies Posted September 4, 2001 Thanks for the reply. I will give them all a try and see which works best for me. Once again thanks a bunch.
Recommended Posts
This topic is 8485 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now