Dear Sajjad!
AOA
I worked on your request and have done as you requested. The sample db is attached herewith for your reference and guidance. The idea is taken from pbaldy's post.
There are three tables in the db,
tblTest
tblComponent
tblTestResults
A combo box, a list box with multi selected option true. combo box is populated from tblTest, Listbox is populated from tblComponent, and a button on the form which have the following code:
Code:
Private Sub cmdEntry_Click()
Dim ctl As Control
Set ctl = Me.LstComp
For Each varItem In ctl.ItemsSelected
CurrentDb.Execute " INSERT INTO tblTestResults " _
& "(tblTestID, tblComponentID) Values " _
& "('" & Me.cboTest.Value & "'," & "'" & ctl.ItemData(varItem) & "')"
Next varItem
End Sub
Records will be added to Your tblTestResults the number of times the components selected, each componentDI will be added to the table along with the TestID selected in combo box:
Hope this fulfill your requirements.
Good Luck!