Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Validation: Combination of 2 fields must be unique

180 views
Skip to first unread message

Christoph Kaufmann

unread,
Apr 7, 2012, 4:50:53 AM4/7/12
to
FMP 10: what's best practice to ensure a combination of two fields is
unique?

Here's what I did:

Set up a third data field (text) with auto-enter calc Field1 & "-" &
Field2 and ask set valdiation to unique.

Seems to be working, but maybe I'm looking to far. Better ways?

What didn't work:

Setting up an auto relation based on the two fields and put and count
the related records in the validation of one of the fields (must be
lower than 2). Doesn't work because the count shows 2 after commit, and
validation checks before commit. Can't ask for less than 1 related
record because this prevents any change.
--
http://clk.ch

Howard Schlossberg

unread,
Apr 7, 2012, 12:52:15 PM4/7/12
to
On 4/7/2012 1:50 AM, Christoph Kaufmann wrote:
> FMP 10: what's best practice to ensure a combination of two fields is
> unique?
>
> Here's what I did:
>
> Set up a third data field (text) with auto-enter calc Field1& "-"&
> Field2 and ask set valdiation to unique.
>
> Seems to be working, but maybe I'm looking to far. Better ways?
>
> What didn't work:
>
> Setting up an auto relation based on the two fields and put and count
> the related records in the validation of one of the fields (must be
> lower than 2). Doesn't work because the count shows 2 after commit, and
> validation checks before commit. Can't ask for less than 1 related
> record because this prevents any change.


I would go with your technique of an added relationship to base your
calc'd validation. Base your validation, however, on THREE fields: the
two whose combination must be unique, PLUS the third based on the unique
primary key fields NOT being equal. That way, you need only test for
the count being >0 (or better, avoid the count by just testing that the
related key field isempty).


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Howard Schlossberg (818) 883-2846
FM Professional Solutions, Inc. Los Angeles

FileMaker Certified Developer
Associate Member, FileMaker Business Alliance

Helpful Harry

unread,
Apr 7, 2012, 5:38:32 PM4/7/12
to
In article <1ki6gac.7lieo26ifsk0N%clkau...@gmx.ch>, clkau...@gmx.ch
(Christoph Kaufmann) wrote:

> FMP 10: what's best practice to ensure a combination of two fields is
> unique?
>
> Here's what I did:
>
> Set up a third data field (text) with auto-enter calc Field1 & "-" &
> Field2 and ask set valdiation to unique.
>
> Seems to be working, but maybe I'm looking to far. Better ways?

I'm not sure which version of FileMaker made the change to allow
Auto-enter Calculation to be re-calculated, but in older versions this
won't work if the user changes one or both source data values.

To get around this you have to lock the source fields from being user
changed and instead have a Button, Script and a couple of Global Fields to
change the data and re-test the validation.

Helpful Harry :o)
0 new messages