Page 1 of 1

Subform with non direct foreign key relationship

Posted: Fri Dec 13, 2019 3:17 pm
by stevedb
Hi,
Is there a way I can add a subform that does not have a direct relationship with the table used for the parent form?
I have a form in which I want a subform just to add rows to a database. The logic is along the lines of: I have hardware assemblies, assemblies have multiple revisions and at a particular revision there are multiple serialNumbers for things made to that revision.
So I have assembly, assemblyRevision and serialNumber tables.
I want to choose an assembly from a browse form (table assembly) to open an edit form for that assembly. On that form I want a subform (table serialNumber) where I can just add serial numbers along with their revision. I can populate the reference to assemblyRevision in the subform with javascript.
My serialNumber table does not contain any reference to the assembly table, just the assemblyRevision table.

I've basically got all this together - but I can't get it to work because by subform 'requires' a foreign key and I can't seem to disable this or put something in there that will make the UPDATE query work.

Hope this makes sense.

Cheers,
Steve

Re: Subform with non direct foreign key relationship

Posted: Fri Dec 13, 2019 3:41 pm
by Janusz
maybe you can try to use iframe placed on the main edit form

Re: Subform with non direct foreign key relationship

Posted: Fri Dec 13, 2019 3:57 pm
by stevedb
I can't get iframes to allow me to add multlple rows to a table in the same way subforms does in grid mode.

Re: Subform with non direct foreign key relationship

Posted: Wed Dec 25, 2019 1:42 pm
by admin
stevedb,

1 - I would create a Form for assembly.

2 - Then create a Run Object (iFrame), on that Form, that displays all the matching assemblyRevision records.
This might help... https://www.youtube.com/watch?v=4ZRRVMlcc34

3 - Finally, I would create a Subform Object on the assemblyRevision Form that holds serialNumbers which relate to each assemblyRevision record.

That way you can start by selecting or adding an assembly record, add or edit assemblyRevisions (in the iFrame) and add serialNumbers to the correct assemblyRevisions via a Subform.


Steven