henrik_ahlgren Posted March 29, 2002 Posted March 29, 2002 I have field which contains a uniqe primary key. When a user enter a value into this field in a new record I want to check for duplicates and show a message if the record already exist or better exit the create new record and show the existing. If the record don
henrik_ahlgren Posted March 30, 2002 Author Posted March 30, 2002 It was a bit crazy but should work. But I can
danjacoby Posted March 30, 2002 Posted March 30, 2002 A crazy thought -- Create a self-relationship (i.e. relate the field to itself). Also create a global text field and enter the word "Duplicate" into it (put the field on a layout, go to Browse mode & enter the word, then go back to Layout mode and delete the field). Now create a portal based on the self-relationship & make it 1 row high. Put the related global field into the portal and disallow entry. Place the portal to the right of the entry field and make sure no lines show. Now, if the entry is not unique, the word "Duplicate" will appear to the right of the field. You can explain in your message that either the entry is a duplicate if the word is showing, or violates the other validation if the word isn't showing.
Rigsby Posted March 30, 2002 Posted March 30, 2002 Ok, this is maybe complicated for anyone who’s never used anything like it, so I will try to explain it as clearly as I can without going into too much detail. There are also probably many more very good ways to do this, but this is the way I tend to use to deal with multiple validations. The trick is not in the validation, i.e. someone enters something and then a validation tells him or her its not good, the trick is to stop him or her entering something wrong in the first place. This system works easily for many sets of criteria (validations). The first is to deal with duplicate entries: Create a global field (lets call this GLOB1) Now create a self relationship between GLOB1 and the field where the user would normaly enter his or her value (Lets call this field ENTRY), so GLOB1::ENTRY Now on the layout where the user enters the value, replace the ENTRY field with GLOB1, so the user enters the value here instead. Now create a script that uses the Count (GLOB1::ENTRY, ANYFIELD) to determine if the value entered exists or not. If the value is found over the relationship, show a message and exit the script. If no related value is found use the SetField step to set the ENTRY field to GLOB1 and then empty GLOB1. You can play around with this to test for other invalid entries, or now use the validation from ENTRY to validate with its own message if the validation fails. You can also play around with the layout here, laying ENTRY set to transparent and no entry, over GLOB1, for example, to make it look as though it really is ENTRY. I use this global field with a script idea a lot in my solutions, as it allows for a lot of flexibility in controlling data input and keeps the validations free for more sensitive messaging. So, for example, I’ll use the script to check for duplicates, control the length of text entered, format the text with PROPER, or LOWER etc. and or many other things that can be controlled at this level. However, if you have a layout with lots of fields that have to be checked, use a related file with just one record instead of global fields. Then, when all the data has been checked, import the related record into your solution and delete it from the related DB. I hope at least some of this helps, Rigsby
danjacoby Posted March 30, 2002 Posted March 30, 2002 My idea didn't work anyway -- I told you it was a crazy thought. What happens when I post after midnight.
Rigsby Posted March 30, 2002 Posted March 30, 2002 Hey Dan! After midnight...... Some people in the good old EU start to read with fresh eyes! LOL Where there's a way there's a will! :-)
danjacoby Posted March 31, 2002 Posted March 31, 2002 Actually, Rigsby, where there's a will there's relatives.
Rigsby Posted March 31, 2002 Posted March 31, 2002 And where there's no Will, there are even more relatives, their dogs, girl/boy-friends and anyone who thinks they might have a chance! Like the joke! Rig!
henrik_ahlgren Posted April 1, 2002 Author Posted April 1, 2002 Thank's Rigsby! That was exactly what I needed, just couldn't get it right by myself. Now I have solved the last known problem so tonight my new DB will come up on the server and meet the users tomorrow morning. Wish me luck
Recommended Posts
This topic is 8343 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