Topic: Many To Many Related Tables

Good Evening everyone,

I was trying to figure out which is the correct procedure or way using MVD components to relate two tables with many to many relationship?
Firstly I was thinking about using tablegrid but I don't know if it's the correct way. Then I add another form with the two comboboxes and make them store the info (example, I want to relate printers with its consumables, because 1 printer has many consumables and one consumable is compatible with many models).

Also is there any way to use something like subform? Or tablegrid as subform?

I attach the sample to make it easier to understand what I want to achieve. (I know it's a mess but hopefully I did something right big_smile )
As you can imagine I'm freshman with less knowledge of how to use the MVD properly.

Thank you for any help.

Post's attachments

Attachment icon relationships_new2.zip 341.22 kb, 100 downloads since 2022-08-23 

Re: Many To Many Related Tables

Example

http://myvisualdatabase.com/forum/viewtopic.php?id=1086

Re: Many To Many Related Tables

Thank you Sparrow.

I'll check it.

Re: Many To Many Related Tables

Hi KTommy, Sparrow,
As always with MVD, there are different approaches you can take.
Here is one possibility (see attachment). 
The data is set up in a many to many configuration using a printer master list, a consumable master list and a matrix of 'where used'.  Then on Form1, simply click on a printer to see what consumables it uses or on a consumable to see which printers uses it.
I think this could also address your question about using a tablegrid as a sort of subform.
It's all standard MVD with no script required.
Hope this helps,
Derek.

Post's attachments

Attachment icon many2many.zip 337.73 kb, 124 downloads since 2022-08-24 

Re: Many To Many Related Tables

Good afternoon everybody,

First of all I want to apologize for my "annoying" and constant posting with probably silly questions. I try to understand the logic that works with this magnificent application; it really rocks, and until I finally figure out the (to be honest my son found it accidentally lol ) I waste everybody's time. He (my son) download an invoice example and there was the answer that I was looking for sad

Derek I cannot count how many times you solved my problems and once again you show me exactly what I was searching for plus you gave me a
huge idea of how to adjust another part of my main project. Once it will be finished I'll publish it for everyone.

Thank you once again.

Re: Many To Many Related Tables

Hi Kula,
Not need to apologise - we were all beginners at one time or another.
And it's never a waste of anyone's time either - whenever I try to answer a question on the Forum, I often find some small feature that I hadn't realised was there so it helps me as well;  there is much more to MyVisualDatabase than you initially realise.
Regards,
Derek.