Reputation: 606
I'm facing issues on editing and saving records in joined table. Here are my tables:
Table1:
ID_Table1 (PK)
Name
Surname
Table2:
ID_Table2 (PK)
Street
Address
JoinTable:
ID_Table1 (FK)
ID_Table2 (FK)
Now, let me explain, I hope you'll understand....
I have a form, with recordsource of Table1 records. When I right-click on current record, I open form with JoinTable recordsource, using this code:
DoCmd.OpenForm "JoinForm", , ,"ID_Table1=" & Forms![Table1Form].Form![ID_Table1]
This code should open JoinForm on exact record as selected in Table1Form, If there are any related records allready in JoinTable. But It's not working correctly.
My construct of JoinForm :
I have replaced ID_Table2 field with Combobox that lists Table2 records and stores It's selected value in ID_Table2 field (FK - JoinTable).
For ID_Table1 (FK) - I have deleted It, and instead of that I added Textboxes that uses DLookup function to display records from Table1 that are being edited (users demand).
So, first problem is storing an ID_Table1(FK) when you try to save a record. I solved this by saving It's value whenever User selects Combobox value - in Before_Update event :
Me.ID_Table1= Forms![Table1Form].Form!
This successfully updates both field in JoinTable (ID_Table1 and ID_Table2), but when I close JoinForm and repeat opening of JoinForm with right-clicking from Table1Form, no records are shown although they exist in JoinTable with this ID_Table1 record. This is second problem.
Can anybody point me to right construction of this JoInForm, or any other ideas on how to solve this problem, It's frustrating !!
Upvotes: 0
Views: 73
Reputation: 606
I have no idea what went wrong, but I re-created Joinform, and now everything works as before. I guess there was some kind of Form or DB corruption or Access bug, I don't have a clue. Problem solved.
Upvotes: 0