CONTINUOUS MASK FILTERED BY CASCADING COMBOXES (MANY-TO-MANY RELATIONSHIP):

Faoineag

Registered User.
Local time
Yesterday, 23:45
Joined
Jan 7, 2018
Messages
62
I have a database of products, I need to enter as many details as possible for each product, I found very useful the Nested SubForms solution, so I created 4 nested subforms. Suppose I am entering the details of an athletics starting block, first I determine whether it belongs to the category race blocks or training blocks, then in the subform "TipoProdotto" I write "Race Blocks"; then I want to define the types of materials (in the subform "TipiMateriali" I indicate the types of materials whose details I will indicate, so: the material of the structure, the coating of the blocks, etc.); then in the subform "TipoMateriale" (here the name is confusing, I could have used just Material, I don't know why I didn't) I indicate the corresponding items, so if in "TipiMateriali" I select "structure material" in the subform "TipoMateriale" I write "aluminum", "steel", if in the subform "TipiMateriali" I select "block coating" in the subform "TipoMateriale" I will write "rubber", "synthetic surface", finally in the last subform, the form "Product", after selecting the values I want in the previous subforms I will write the name of the product.
In another mask, "SubCategoriesTypeProduct," I have two combined drop-down boxes that filter the query on which the subform is based, and so far everything works. What I would like to do is to also add the other two fields, "TipiMateriali" and "TipoMateriale" so that they filter the submask. In "Maschera2" I tested and inserted the combobox "TipiMateriali" and "TipoMateriale" because, for example, I would like to see the list of "competition starting blocks" (TipoProdotto) whose guiding material (TipiMateriali) is Aluminum (TipoMateriale), unfortunately, however, the subform remains empty.
"Maschera2" is based on the query "qryProducts_ProductsSubCategories". I attach the screenshots. I thank those who can help me
 

Attachments

  • Form TipoProdotto+TipiMateriali+TipoMateriale+Prodotto.png
    Form TipoProdotto+TipiMateriali+TipoMateriale+Prodotto.png
    56.3 KB · Views: 31
  • qryProdotti_ProdottiSottoCategorie.png
    qryProdotti_ProdottiSottoCategorie.png
    52.5 KB · Views: 32
  • Relazioni Molti a Molti.png
    Relazioni Molti a Molti.png
    31.3 KB · Views: 32
  • SottocategorieTipoProdotto.png
    SottocategorieTipoProdotto.png
    139.5 KB · Views: 32
Make sure that your comboboxes are returning the correct field value. They likely display a text description, but need to return the ID value. If the wrong field is bound in the combo or the combo does not include the ID in the rowsource you will not be able to return records.

FYI. I think Maschere does not translate well. I assume it means Forms not Masks. We would call it a subform not a submask. This is a little confusing since a Mask in english in Access means something completely different.
 
Last edited:
I have a database of products, I need to enter as many details as possible for each product, I found very useful the Nested SubForms solution, so I created 4 nested subforms. Suppose I am entering the details of an athletics starting block, first I determine whether it belongs to the category race blocks or training blocks, then in the subform "TipoProdotto" I write "Race Blocks"; then I want to define the types of materials (in the subform "TipiMateriali" I indicate the types of materials whose details I will indicate, so: the material of the structure, the coating of the blocks, etc.); then in the subform "TipoMateriale" (here the name is confusing, I could have used just Material, I don't know why I didn't) I indicate the corresponding items, so if in "TipiMateriali" I select "structure material" in the subform "TipoMateriale" I write "aluminum", "steel", if in the subform "TipiMateriali" I select "block coating" in the subform "TipoMateriale" I will write "rubber", "synthetic surface", finally in the last subform, the form "Product", after selecting the values I want in the previous subforms I will write the name of the product.
In another mask, "SubCategoriesTypeProduct," I have two combined drop-down boxes that filter the query on which the subform is based, and so far everything works. What I would like to do is to also add the other two fields, "TipiMateriali" and "TipoMateriale" so that they filter the submask. In "Maschera2" I tested and inserted the combobox "TipiMateriali" and "TipoMateriale" because, for example, I would like to see the list of "competition starting blocks" (TipoProdotto) whose guiding material (TipiMateriali) is Aluminum (TipoMateriale), unfortunately, however, the subform remains empty.
"Maschera2" is based on the query "qryProducts_ProductsSubCategories". I attach the screenshots. I thank those who can help me
Are you able to upload a copy of the database?
 
Now the query is filtered, however, all the products that belong to the filters are listed (I still don't understand with what criteria) and the number of products doesn't change, whereas it doesn't. For example, if you look at the two screenshots, the products are always 13 regardless of what I select in the last two comboboxes.
 

Attachments

  • 01.png
    01.png
    115.4 KB · Views: 27
  • 02.png
    02.png
    117.5 KB · Views: 27
You may just need to scramble any private information fields. Here is a technique
 
I thank you for the help you gave me, but I decided to give up: I tried to recreate another database but it is very complicated, as is the other solution. However, I would ask you if you can show me some tutorials or videos or anything that can suggest some solution to filter a continuous mask with multiple cascading combo boxes linked together by many-to-many relationships. Thanks again
 
I tend not to do this in a query that uses control parameters. It gets overly complicated and it is not flexible.
Since I often build searchable forms with lots of controls, I have built a module that does all the work. I can add any number of controls with no problem.

 
I recreated the same db from which I copied the idea of the nested subforms and here too the error occurs again: if you go to the TipoProdotto form, select:
Competition
Spar material
Aluminum
you see
PBS17
or
Competition
Spar material
Steel
you see
PBS15

then if you go to the "frmProdotti" form and in the "Product Type" combos select Competition Starting Blocks, in "TipoMateriali" select Spar Material and in "Material" select Aluminium, 6 products appear.


@MajP Now I'll look at your answer, thanks
 

Attachments

I recreated the same db from which I copied the idea of the nested subforms and here too the error occurs again: if you go to the TipoProdotto form, select:
Competition
Spar material
Aluminum
you see
PBS17
or
Competition
Spar material
Steel
you see
PBS15

then if you go to the "frmProdotti" form and in the "Product Type" combos select Competition Starting Blocks, in "TipoMateriali" select Spar Material and in "Material" select Aluminium, 6 products appear.

Hi
Hi When i go into the Prodotti Subform there is only an option to select up to 5 Products?
There is no need for any Cascading for anything.
You have a straight Main Form with Multiple Subforms

I think you need to define which materials belong with each Product.

Can you let us know which materials belong with Each Product?

PBS17 - list Materials available
PBS15 - same
PBS15-T - Same
10116 - same
@MajP Now I'll look at your answer, thanks
 

Attachments

Last edited:
This works for me. You will have to change [Forms] back to [Maschere]. I had to change it to work. This uses the technique from my thread.
Code:

Code:
Dim fltrProdotto As String
  Dim fltrTM As String
  Dim fltrMat As String
  Dim fltr As String
  'one per control
  fltrProdotto = GetFilterFromControl(Me.cboTipiMateriali)
  fltrTM = GetFilterFromControl(Me.cboTipiMateriali)
  fltrMat = GetFilterFromControl(Me.cboMateriale)
 
  fltr = CombineFilters(ct_And, fltrProdotto, fltrTM, fltrMat)
  If fltr <> "" Then
    Me.Filter = fltr
    Me.FilterOn = True
  Else
    Me.Filter = ""
    Me.FilterOn = False
  End If

As I stated in my thread, you can add as may controls as you want the code grows by one variable and one line per each control.
 

Attachments

Hi When i go into the Prodotti Subform there is only an option to select up to 5 Products?
There is no need for any Cascading for anything.
You have a straight Main Form with Multiple Subforms

I think you need to define which materials belong with each Product.

Can you let us know which materials belong with Each Product?

PBS17 - list Materials available
PBS15 - same
PBS15-T - Same
10116 - same
Thanks Mike, so I can use the "nested forms" form not only to insert the characteristics of each product (I inserted this subform in the product sheet so that I can insert, for each product, all the characteristics that interest me), but also to do a product search starting from the "Product Type" value (i.e., by selecting the ProductType, the MaterialTypes and the Material, I can see which and how many products have this characteristics)? Out of curiosity but above all my personal Access culture, could you tell me what the error is in my method? that is, use a continuous mask with all the combos filtering. Thanks again
 
Thanks Mike, so I can use the "nested forms" form not only to insert the characteristics of each product (I inserted this subform in the product sheet so that I can insert, for each product, all the characteristics that interest me), but also to do a product search starting from the "Product Type" value (i.e., by selecting the ProductType, the MaterialTypes and the Material, I can see which and how many products have this characteristics)? Out of curiosity but above all my personal Access culture, could you tell me what the error is in my method? that is, use a continuous mask with all the combos filtering. Thanks again
MajP has sorted out your Search Form
For your Data Input Forms I added a Combobox for materials
Now when you select a Product only those materials associated with that product are displayed.
 

Attachments

This works for me. You will have to change [Forms] back to [Maschere]. I had to change it to work. This uses the technique from my thread.
Code:

Code:
Dim fltrProdotto As String
  Dim fltrTM As String
  Dim fltrMat As String
  Dim fltr As String
  'one per control
  fltrProdotto = GetFilterFromControl(Me.cboTipiMateriali)
  fltrTM = GetFilterFromControl(Me.cboTipiMateriali)
  fltrMat = GetFilterFromControl(Me.cboMateriale)
 
  fltr = CombineFilters(ct_And, fltrProdotto, fltrTM, fltrMat)
  If fltr <> "" Then
    Me.Filter = fltr
    Me.FilterOn = True
  Else
    Me.Filter = ""
    Me.FilterOn = False
  End If

As I stated in my thread, you can add as may controls as you want the code grows by one variable and one line per each control.
Thanks MajP, I'm still too ignorant to understand your code, but in the database I noticed that, by selecting the same values in the "Product Type" frm and in the "Products frm", the result is different, as can be seen in the screenshot, or in the frm "Product Type" there is only one product, while in the "Products" form there are 4 products (but only one correct one, the PBS17)
 

Attachments

  • 2024-07-12_21h56_22.png
    2024-07-12_21h56_22.png
    68.7 KB · Views: 22
You forms query does not make any sense as far as I can tell. You are missing a join so you have created a cartesian product.
Rel.png
 
Last edited:
Thanks MajP, I added the join, I modified the relationships, but now the query no longer returns any value, where am I wrong? Thank you
 

Attachments

As far as I can tell this is not correctly designed. I can not make any sense out of it.
Can you explain what is in each table and how they relate. The relationship does not look correct and neither does the query. You have foreign keys in multiple tables that are not used.

products.jpg


I assume Prodotti (Products) is the top level table of Products that are made

I think that junction table (ProdottoMateraile) might have too many foreign keys
1. If TipoProdtto is related to TipiMateriali then you make the relationship through those tables and there is no foreign key in the ProdottoMateriale
2. If Materiale relates to TipiMateriali you relate through those tables and no foreign key in Prodotto

My first guess is this is the correct design.
prod2.jpg
 
As far as I can tell this is not correctly designed. I can not make any sense out of it.
Can you explain what is in each table and how they relate. The relationship does not look correct and neither does the query. You have foreign keys in multiple tables that are not used.

View attachment 115094

I assume Prodotti (Products) is the top level table of Products that are made

I think that junction table (ProdottoMateraile) might have too many foreign keys
1. If TipoProdtto is related to TipiMateriali then you make the relationship through those tables and there is no foreign key in the ProdottoMateriale
2. If Materiale relates to TipiMateriali you relate through those tables and no foreign key in Prodotto

My first guess is this is the correct design.
View attachment 115095
@MajP Your hypothesis is correct, in the sense that it works on the example database I sent you. Unfortunately, not in the original database, but having your trace, I try to understand the reason for the error. Thanks again
 
The code works fine, it is the query that is incorrect and likely the table design. If you get a correct query the code will still work.
 

Users who are viewing this thread

Back
Top Bottom