I am working on a membership database for a Rod and Gun Club that records member information, along with their interests. I have the following relevant tables:
Members
MemberID (PK)
Name......
InterestCategories
InterestCatID (PK)
InterestCatDesc
Interests
InterestID (PK)
InterestCatID (FK)
InterestDesc
MemberInterests
MemberID (FK - Members)
InterestID (FK - Interests)
I have a form that the secretary uses to record member information along with their interests. On that form I have a section for interests, with headers for categories. Under those headers I have combo boxes that select interests for that category:
(SELECT InterestID, InterestDesc FROM Interests WHERE InterestCatID = (Whatever category the combo box is under).
What I would like to be able to do is enter/update the members information and cycle through each combo box(all Tags have been set to "Interests") and append that to the MemberInterest table with the MemberID.
I have tried to work with the Tag property and use an append query:
What happens is I get the same number of entries in the table as there are combo boxes with whatever is in cboInterest1. I know that's because that's what the SQL tells it to do, so I am half way home.....
What I need help with is telling the SQL to look at each combo box and add entries from each one, not just the first one. I am hoping to get some code that will loop through each combo box and take it's value and append it to the table.
Thanks in advance for any help.
Members
MemberID (PK)
Name......
InterestCategories
InterestCatID (PK)
InterestCatDesc
Interests
InterestID (PK)
InterestCatID (FK)
InterestDesc
MemberInterests
MemberID (FK - Members)
InterestID (FK - Interests)
I have a form that the secretary uses to record member information along with their interests. On that form I have a section for interests, with headers for categories. Under those headers I have combo boxes that select interests for that category:
(SELECT InterestID, InterestDesc FROM Interests WHERE InterestCatID = (Whatever category the combo box is under).
What I would like to be able to do is enter/update the members information and cycle through each combo box(all Tags have been set to "Interests") and append that to the MemberInterest table with the MemberID.
I have tried to work with the Tag property and use an append query:
Code:
Dim ctl As Control
Dim SQL As String
SQL = "INSERT INTO MemberInterests (MemberID, InterestID) VALUES (txtMemberID, [b]cboInterest1[/b])
For Each ctl In Me.Controls
If ctl.Tag = "Interest" Then
DoCmd.RunSQL SQL
End If
Next ctl
What happens is I get the same number of entries in the table as there are combo boxes with whatever is in cboInterest1. I know that's because that's what the SQL tells it to do, so I am half way home.....
What I need help with is telling the SQL to look at each combo box and add entries from each one, not just the first one. I am hoping to get some code that will loop through each combo box and take it's value and append it to the table.
Thanks in advance for any help.