I'm trying to create a customer database application with a central customer table and several subforms. I want a subform become available in another subform with information depending on the choosen customer. I think I can best explain with the following example of a rental car company: I have customers, cars and licenses. Each is a independent form/table. Then I have subforms of the customer table to assign licences and cars to each customer. Maybe here the following db structure plan helps:
So far everythings works. I can go to the table 'cust_car', open the form, pick a customer (foreign key from 'customer'), choose a car (foreign key from 'cars') and save this. Now I want from inside this form to show all the licences the customer has. It's really inconvenient to go back to the 'customer' table and check this manually. My plans looks like this:
I think the best way would be subform item, but it seems the subform items always use the table's primary key for the relation and I can't choose another key. In my case I would need 'cust_car_customer' from the 'customer' table as key and not the PK 'cust_car_id', which seems to be unchangeable for the subform object...
My workaround idea is to run the form 'cust_lic' in an iframe form inside 'cust_car' and use the field 'cust_car_customer' as filter. Also this works. The problem now is that when I click "add" in the iframe the form is empty and not yet conncted to the customer I chose in the beginning. Of course I could choose the customer now manually, but that means additional effort and possible mistakes - especially when there lots of customers with similar names. Apart form this rental car example, that is real problem in my real use case.
Does anybody know a way how to transport the choosen 'cust_car_customer' (foreign key) from the first subform and use it to prefill 'cust_lic_customer' when adding a new record? Or does anybody have an idea for another workaround?
I'm looking forward to your ideas and help
