Link to home
Start Free TrialLog in
Avatar of Dennis_Todd
Dennis_Todd

asked on

Updating Junction table

I have table A and table B with a many-to-many relationship.  I have table C as a junction table.

I have a form that browses through table A with a subform that shows a summary of the related items from table B.  If I double click any of the items in the summary subform, I get another form that allows me to edit all the items in table B.  The relationships and the junction table are working fine.

My problem is this:  I have to initially create the items for table B by filling in a new summary line on the subform.  Apparently Access is updating the junction table for me.  That's nice.

But what I really want is to have a button labeled "add" that will cut out the middle man and just pop up a blank form for creating a table B row.  I can do that of course, and the row is created in table B, BUT THE JUNCTION TABLE IS NOT UPDATED.  

How do I update the junction table in this scenario??

(sorry for the long description :-)

Thanks for your help!
Avatar of nico5038
nico5038
Flag of Netherlands image

Just create a form with the DataEntry option set to Yes for the form that's defined on table B. (Just select properties right after opening the form in design mode and go to the data tab)

Then place a button and select the form open for this created form.

Clear ?

Nic;o)
Avatar of Dennis_Todd
Dennis_Todd

ASKER

This is exactly what I've done (although it makes no difference what I set the DataEntry value to).  I prefer to have DataEntry turned off (so it's clear that you HAVE to add data by clicking the button rather than filling in a blank summary line on the summary form).  I tried it with DataEntry turned on as you suggest, however, but I still have the same problem.  The junction table does NOT get updated when I enter the data.

Let me clarify a little more:

I have 1 form (bound to table A) which contains 1 subform (bound to table B).  I want to click a button to invoke a second form (third, if you count the subform) where I enter the full data for a new row in table B.  After I close the third form, I programatically do a requery which should make the new table B data appear in the subform.
ASKER CERTIFIED SOLUTION
Avatar of nico5038
nico5038
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I must be doing something wrong, because I clicked my add button, filled out the form, closed it and went so far as to close down Access and come back.  The row of new data gets inserted into table B ok, but the junction table does NOT get a corresponding row added to it.
Then I would suspect there's a filter (criteria) on a field blocking the newly created row, or your looking/using the wrong row to select from (happened to me too). Are you sure the B key is originated from the B-table and not from the DISTINCT C-tableentries...

Nic;o)
for Dennis_Todd

No comment has been added for the last two months.
So it's time to clean up this TA.
I will leave a recommendation in Community Support that this question is:
 - Answered by: nico5038  
Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

Nic;o)
Per recommendation, force-accepted.

Netminder
CS Moderator