Highlighted

Simple way to test that values in a table are unique?

Avatar

Guest

11-12-2008

Is there any property to force repeating fields to be unique? I have multiple rows in a table and I want each instance of the "Name" field (Name[*]) to be unique.



I'm hoping there's a property I can select, so I don't have to add a script to test every row in the table to see if the value already exists. There are a lot of scripts running on this table already, so I'm afraid that more looping and testing will impact the performance as more rows are added to the table.

Replies

Highlighted

pguerett

11-12-2008

It is unique by default. The somExpression is what you want (not the name) and that is unique. There is an occurance number on the row (as that is the repeating subform) and thats what makes it unique. So to address the field it woudl be something like this:



form1.Page1.Table1.Row[occurance number].Name.rawValue
Highlighted

Avatar

Guest

11-12-2008

It's the value of the "Name" field that needs to be unique. I need to prevent the user from entering the same name more than once.



Say the table has five rows with fields called Name, Rank, SerialNumber. I'd like to prevent the following entries:



Thing1, private, 12345

Thing2, captain, 23455

Thing2, corporal, 66666

Thing2, lieutenant, 55555

Thing3, sgt., 99999



I was hoping I had missed a setting in the one of the properties for the field that would define it as unique. I know it's a long shot, but it would save a lot of time at runtime.
Highlighted

pguerett

11-12-2008

No there is nothing like a check box that will only accept a unique input. You woudl have to get the value and test it against all other values in the table. You could do it on the exit event of the field and if you get a match then pop up a message box and return the cursor to that field.