Hello Louis,
yesterday I wrote a reply that took me about 20min. I copied everything to the clipboard (always do that with longer posts in case something goes wrong on submit) and then hit submit. This made my Firefox crash. After opening it again, I wanted to paste the post from the clipboard - but is was gone. I found out that clipboard gets erased when application crashes that you copied the content of the clipboard from. That was very frustrating.
But now I type it again.
You have 2 tables: companies, purchases.
You need to setup 2 Seblod content types: companies, purchases.
Content type companies form fields:
comp_key, comp_firm, comp_address, comp_city, comp_state
Content type purchases form fields:
purch_key, comp_key, purch_date, purch_purchase, purch_price
For those fields you set the storage to free-table and then choose your respective tables for each content type. James Morrell has a
great video on Seblod storage options.
For the comp_key field in the
purchase form use a
dynamic select field that gets populated from your company table. Use comp_firm as Options Name and comp_key as Options value. Set the storage to the comp_key field in your purchase table.
Now when you open the purchase form, you get a select field with all the companies in it. You can choose a company, fill in your purchase data and the purchase will get saved to your purchase table with the correct company key.
If you want to check by comp_key whether a company already exists:
Set up a List&Search for your company content type. In the search tab incude the comp_key field and a submit button. When you go to the search form, you type in a company key and hit submit. If a company is found, you can redirect to the purchase input form. If no company is found, you can redirect to the company input form and add the company.
For the company form you can add a redirect after submit to the purchase form.
This should be it. Let me know if it works out for you.
Gerhard