Jump to content
Sign in to follow this  
Speekless

Child-parent record creation

Recommended Posts

I have two tables, X and Y, the relationship is one-to-many.

X has the following fields: kp_ID_X, name (unique)

Y has a foreign key kf_ID_X to X, and some other fields .

On the Y layout I have the "name" field from the related record in X. The problem now is that when I want to enter a value that already exists into that field, it will show an error saying it needs to be unique (because "name" is defined to be unique in the X table, obviously).

The behavior that I would be looking for is that a new record is created if the value doesn't exist; if the value already exists I would like it to change to the right foreign key.

Does anybody have a simple explanation on how to achieve this?

Thanks!

Pim

Share this post


Link to post
Share on other sites

Thanks ;)-) That comes very close, but when I change the "name" value from the Y layout, it changes on all records that share that value. What I'd like to do is when the value is changed it just creates a new record in X.

So I'll have to tweak things a little bit, but I'm sure your example will come in very handy.

Maybe I'm wrong, but it must be possible to do this with only one TO of X (XY in your example), right?

I also was wondering, in your script, what is the "xor 1" part for after isEmpty?

Thanks for your time!

Share this post


Link to post
Share on other sites

Maybe I'm wrong, but it must be possible to do this with only one TO of X (XY in your example), right?

No I have not tossed it there just in vain, you need to make a selfjoin on the values already stored, to get the first occurrence of the value or rather the ID of the record. It should be said that several fields values could be matched to prevent two John Smith living in two different locations eliminate the other.

http://sixfriedrice.com/wp/deleting-duplicate-records-in-filemaker/

What I'd like to do is when the value is changed it just creates a new record in X.

Where exactly was this mentioned in the initial mission statement?

I also was wondering, in your script, what is the "xor 1" part for after isEmpty?

Similar to not IsEmpty( ...it's simply a logical switch which I find faster to hit when clicking the components to place in the equations.

--sd

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

By using this site, you agree to our Terms of Use.