You appear to have these relationships:
To add a new child, you need to add two new records--one in the child table and in the Parent_2_Child join table and the necessary primary key from the new child record must be entered into the new join table record along with the primary key from the Parent record in order to link the new Child record to the current Parent record.
Set Variable [$ID_Par.pk; value: PARENT::PARENT_ID.pk]
Go to Layout [Contacts]
Set variable [$ID_Contact ;value: Contacts::Con_ID.pk]
Go to Layout [Participant_2_contacts]
Set Field [Participant_2_contacts::PAR_ID.fk ; $ID_Par.pk]
Set Field [Participant_2_contacts::CON_ID.fk ; $ID_Contact]
Go To Layout [original layout]
Though your original script should work if you enabled "allow creation of records via this relationship" for Participant_2_contacts in the contacts to Participant_2_contacts relationship.
I made those corrections to my script. Also I checked to make sure I enabled "allow creation of records via the relationship for Participant_2_Contacts in the Participant_2_Contact relationship. I've still got something going now. Now I'm creating the new records in both the Contacts and Participant2_Contacts tables as desired but am still not working right on the portal side.
It occurs to me that I neglected to mention something--I don't know if it's causing my problem. Although I have the portal on the Participant layout... it is layered under a Control named "CHILD".
I try adding one last line to the script, after Go to Layout [original layout] which reads: Go to Object[Object Name:"Child"] but it doesn't seem to be having any impact... when I click the add button I have brought back to the first control on the layout, not the second one labeled "Child".
Although I have the portal on the Participant layout... it is layered under a Control named "CHILD".
I don't know what you mean by "layered under a control"
The "allow creation" is an alternative to modifying your script to match mine. You do not need it enabled if you use my script. You DO need it with your original script.
Make sure that $ID_Par.pk is getting a value. I use a button outside the portal for this purpose. It adds a blank record in the portal linked to a new blank record in the third table (contacts in your case).
You may want compare what you have set up to the script in this demo file: http://www.4shared.com/file/dZ0bjclw/ManyToManywDemoWExtras.html
Ok, I'll do that. Actually, I tried looking at the earlier. I tried to isolate just the funtions that correspond to the Basic Setup Layout (excluding elements used for the diminishing value and checkbox utilities. What confused me was the script on the add button on the basic Setup page references a the EvDmVlContacts layout and variable.
In isolating just want I would need to run the Basic Setup I thought I'd only need to Contacts, EVents and Contacts_Events table occurances. I found it confusing that the script referenced a TO that was related to diminishing values. So after some struggle I gave up and thought I'd apprach this differently.
In regard to the scenario above... I find that although my new records are being generated as a result of the script, the serial numbers are not accurate... I have all my serial numbers formatted with five zeros and a number. And all of my primary keys prohibit modification. The ones generated as a result of the add script lack the leading zeros. Do youhave any guess why that would happen?
Ok, well I was working on a layout page that had a three tier tab control and I had my portal placed on the second tab. Just for kicks I got rid of the first tab and now I am creating records through the portal... but my join table is still collecting serial numbers that drop the leading zero from both foreign keys. Have you ever heard of that happening?
Where the serial number should be 000030 what I see is 30, where the serial number should be 000073 I see 73. Could it be the variable? Is there a way to format the variable?
Ahhh, I set my serial numbers to text and now I don't seem to be having that problem. Should serial numbers be in text format?
Check my response to your other post with regards to the demo file. The script just need a layout based on the correct table, it has nothing to do with the diwindling value list example other than that the layout referenced happens to come from that set of layouts.
Personnally, I wouldn't use leading zeroes in my serial numbers in the first place. I'd use a separate field that formats them with leading zeroes if I need leading zeroes to meet the display requirements for a layout or report. I suspect that you have leading zeroes specified for a serial number field of type number. If so, you can change the field types to text and this problem should disappear. When an expression refers to a number field, it's numeric value is what will be returned and that's what gives you 30 instead 000030. You can also try using the getastext function when setting the variables or this expression can preserve your leading zeroes:
Right ( "00000" & SerialNumberField ; 6 )
this last expression is what I use in a calculation field to format serial numbers with leading zeroes.
Oh, I see what you mean. Thanks for all of your time and patience Phil.