RonL,
I have a set up with 3 tables
UniCourse
Tutor and
junction TutorCanTeachJunction
Tutor --->TutorCanTeachJunction<--Course
The tables UniCourse and Tutor are filled already. To populate the junction table, you select the Tutor and the UniCourse, then click the button. This executes an insert query, to add the record to the junction.
Attached is jpg of the simple form I use to populate the junction table
Here is the code associated with the button to save the values from the respective Comboboxes.
Code:
'---------------------------------------------------------------------------------------
' Procedure : btnTeaches_Click
' Author : Jack
' Date : 12-10-2011
' Purpose : To populate TutorCouldTeachJunction Table with
' the id of the tutor and the id of the Course involved.
'Unique index on TutorId & CourseId to prevent duplicates.
'---------------------------------------------------------------------------------------
' Last Modified:
'
' Inputs: N/A
' Dependency: N/A
'--------------------------------------------------------------------------
'
Private Sub btnTeaches_Click()
10 On Error GoTo btnTeaches_Click_Error
20 On Error GoTo Err_btnTeaches_Click
Dim SQL As String
30 SQL = "Insert Into TutorCanTeachJunction(TutorId,CourseId) " _
& "VALUES (" & Me.Combo0 & "," & Me.Combo3 & ")"
40 Debug.Print SQL
50 CurrentDb.Execute SQL, dbFailOnError
Exit_btnTeaches_Click:
60 Exit Sub
Err_btnTeaches_Click:
70 MsgBox Err.Description
80 Resume Exit_btnTeaches_Click
90 On Error GoTo 0
100 Exit Sub
btnTeaches_Click_Error:
110 MsgBox "Error " & Err.number & " (" & Err.Description & ") in procedure btnTeaches_Click of VBA Document Form_frmTutorTeachesCourse"
End Sub
This is the rowsource of combo0(Tutor)
Code:
SELECT TUTOR.ID, TUTOR.Name
FROM TUTOR
ORDER BY TUTOR.[ID];
And this is the rowsource of combo3(UniCourse)
Code:
SELECT UNICourse.CourseID, UNICourse.Coursename
FROM UNICourse
ORDER BY UNICourse.[CourseID];
Update:
RonL suggested the many to Many resolved by 2 1 to Many relationships and a junction table. In my view if he wanted a Cartesian product, he would have said so, or would not have described what he did in his post.
I think Ron expected the junction to be populated automagically -- but it won't. You have to determine which Tutor can teach which UniCourse, select the combination and append to the junction.