Many-to-many - Joint table and form (1 Viewer)

Jimis

New member
Local time
Today, 05:51
Joined
Feb 15, 2022
Messages
28
I must have messed something in my db that gives me a popup window
1645175094145.png

The sFrm_customer_JoinT works fine on its own but in the subform it seems it has an issue. The value from the cbDevCustID which is asked is supposed to update as soon as the Frm_Assets is loaded and then the combo cbCustERP requeries and updates it's data.

I can't seem to find the problem. The query runs fine as long as I have the sFrm_customer_JoinT loaded on its own
 

Attachments

  • test_Jim.accdb
    5.6 MB · Views: 108

mike60smart

Registered User.
Local time
Today, 03:51
Joined
Aug 6, 2017
Messages
1,917
You based the Combobox for selecting the CustERPID on a Query, the query also had a Form reference to the Combobox, the Form also had a requery of the Combobox for selecting the CustERPID???

I removed all of these referencesz and just based the Combbox on the CustERP table

It now works as it should
 

Attachments

  • test_Jim (1).zip
    511.1 KB · Views: 84

Jimis

New member
Local time
Today, 05:51
Joined
Feb 15, 2022
Messages
28
You based the Combobox for selecting the CustERPID on a Query, the query also had a Form reference to the Combobox, the Form also had a requery of the Combobox for selecting the CustERPID???

I removed all of these referencesz and just based the Combbox on the CustERP table

It now works as it should
The query is for the cbCustERP combo to populate according to what is set in cbDevCustID combo. You must not delete it
 

mike60smart

Registered User.
Local time
Today, 03:51
Joined
Aug 6, 2017
Messages
1,917
Jim

What has CustomersERP_T table got to do with CustomersT ???

What you are trying to do is use Cascading Combobox's - this usually means if I select a Customer using the 1st Combobox
then only data related to that selected Customer would appear in the 2nd Combobox.

In your case there is currently no relationship between the 2 tables.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:51
Joined
May 7, 2009
Messages
19,249
i think CustomersERP_T table is already the Junction table.
 

Jimis

New member
Local time
Today, 05:51
Joined
Feb 15, 2022
Messages
28
It's the customer_joinT that shows the relationship.
customerERP can have many DeviceCustomers but not the opposite. So when user selects DevCustID it will update the list of possible selectable custERPID. That's why the query is needed
1645185760581.png


Keep in mind that it works fine if you run the sFrm_customer_joinT. It just doesn't work when it is called as a subform inside Frm_Assets
 
Last edited:

mike60smart

Registered User.
Local time
Today, 03:51
Joined
Aug 6, 2017
Messages
1,917
This is the Relationship Diagram

CustomerERP _T is NOT the linking Table in the uploaded Database
 

Attachments

  • ERP.JPG
    ERP.JPG
    36 KB · Views: 94

mike60smart

Registered User.
Local time
Today, 03:51
Joined
Aug 6, 2017
Messages
1,917
But it is not working
 

Attachments

  • Not Working.JPG
    Not Working.JPG
    39.6 KB · Views: 87

Jimis

New member
Local time
Today, 05:51
Joined
Feb 15, 2022
Messages
28
I don't have an issue with it. When I select a customer I get the correct match below on the CustomerERP

1645191460181.png
 

Jimis

New member
Local time
Today, 05:51
Joined
Feb 15, 2022
Messages
28
This is funny. I don't get the pop-up window when the sFrm_customer_JoinT is open as standalone which means that the subform inside the Frm_Assests is looking for the combo box data from the form outside not the one inside as a subform. Why is that ?
 

Jimis

New member
Local time
Today, 05:51
Joined
Feb 15, 2022
Messages
28
Any suggestions on how to solve this problem ?
 

Jimis

New member
Local time
Today, 05:51
Joined
Feb 15, 2022
Messages
28
Thx for the effort Mike but as I explained your suggestion to delete the query is not helpful for me since that will remove the function that I'm trying to implement.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:51
Joined
May 7, 2009
Messages
19,249
your "form" now has become a "subform", so a change on the Criteria on Query1 is necessary.
see Query1 in design view.
 

Attachments

  • test_Jim.accdb
    5.6 MB · Views: 92

Pat Hartman

Super Moderator
Staff member
Local time
, 22:51
Joined
Feb 19, 2002
Messages
43,603
The only reason for having an autonumber in a table is for it to serve as the PK. If you are not going to use the autonumber in the junction table as the PK, it is best to just remove it.
 

mike60smart

Registered User.
Local time
Today, 03:51
Joined
Aug 6, 2017
Messages
1,917
Hi
Can anyone else confirm that in the database uploaded by arnelgp none of the Forms listed below actually work?

frrmAssets
frmDevices
sfrmCustomerJoin
 

Pat Hartman

Super Moderator
Staff member
Local time
, 22:51
Joined
Feb 19, 2002
Messages
43,603
Yep. They don't work. I guess no one bothered to look at the working example I posted early on.
 

Jimis

New member
Local time
Today, 05:51
Joined
Feb 15, 2022
Messages
28
I downloaded the db and they work fine for me. I got Access 2016
The only reason for having an autonumber in a table is for it to serve as the PK. If you are not going to use the autonumber in the junction table as the PK, it is best to just remove it.
I was planning on changing the relationship of customer_JoinT and AssestsT. It should be the other way around. I will also keep in mind what you said and my change fixes that issue also.

New relationship is this. Removed the AssestsID field from Customer_JoinT.
1645429965029.png


I think the setup is fine now and all forms work ok. My problem is still focused on how to make the user select combo DevCustID then the CustERPID will populate with Query1 according to what user selected, so the user can select only what is offered. The Problem is that I get an error when I try to input values even though the selections are shown correctly because Access tries to add a new record instead of using the existing.
Here is an example. When I select BIOTRANS customer, I get BIOTRANS AE in customerERP but the problem is that this is added as a new record 111 (above) instead of using the existing one which is record ID 3 in customer_JoinT.
1645430453323.png

1645430704598.png

Ofc I wasn't expecting it to be that easy. So I tried to simplify selection by using the ID of customer_JoinT and not the devCustID and custERP separately, something like this below. But it's read only can't actually change it. Note that it's linked with the Frm_Assets
1645432588307.png
 

Attachments

  • 1645432525009.png
    1645432525009.png
    10.8 KB · Views: 80
  • test_Jim3.accdb
    5.6 MB · Views: 90

Users who are viewing this thread

Top Bottom