Struggling with many-to-many (one table) design

Game Analysis

I was wondering if someone to help with the design of this form as I'm having trouble conceptualizing it. It's simply intended to store a database of relational words.

As the title suggests, it's a M2M involving only table:

  • tbl_elements (ID, element)
  • tblJ_elements (IDJ, J_elements1, J_elements2)
  • frm_elements (based on tbl_elements - split form to the left, subform stated below on right)
  • frm_elements_subform (based on tblJ_elements)

-

This is what I would like to happen, as an example (using frm_elements):

  • navigate to volcano (in the datasheet list on the left)
  • enter lava into the entry field on the right (which is the elements2; elements1 is hidden and has the default value set to whatever current record selected in the datasheet)
  • navigate to lava - see volcano listed

-

Of course, this doesn't work as when you navigate to lava, there are no records because there is no juntion table record where elements1 = lava. I would need to have the splitform list based on elements2's field, however that's clearly the same problem.

I can't wrap my head around this as I want to

  • have a splitform datasheet list, listing every record frm tbl_elements
  • select 'volcano' and see the subform on the right
  • enter an associated word, 'lava'
  • then be able to navigate to lava in the datasheet list and see 'volcano' enter there as well

I hope that makes sense and i'm just missing something obvious. I don't want to have to enter the connections twice - going to volcano, adding lava - then going to lava and adding volcano.

Kind regards

Andre

I'd say you need a UNION query as record source of the subform, to cover both directions.
E.g.

SELECT e.ID, e.element
FROM tbl_elements e INNER JOIN tblJ_elements j ON e.ID = j.J_elements1
WHERE j.J_elements2 = Forms!frm_elements!element_ID

UNION ALL

SELECT e.ID, e.element
FROM tbl_elements e INNER JOIN tblJ_elements j ON e.ID = j.J_elements2
WHERE j.J_elements1 = Forms!frm_elements!element_ID

ORDER BY element

frm_elements!element_ID is the element you have selected on the left side.

UNION queries are always read-only, so your subform will be read-only. You need to handle additions and deletions on the right side with VBA.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related