S
spokane29 via AccessMonster.com
I have a list box which I have set to Multiselect=Simple. I want to store
each item selected to its own record. The form I am using is a subform
within a subform. The form name is [frmResponses Subform]. In the form
structure, the main form is frmQuestionaire, the first subform is
tblQuestions, and then tblResponses Subform is a subform within tblQuestions.
When I attempt the code below, I get a Run-time error '2465': Microsoft
Access can't fin the field 'frmQuestionaire' referred to in your expression.
If I change it to jsut the name of the subform [frmResponses Subform] I get
the same error. It errors at the Set frm line.
Any suggestions as to what may be wrong?
Dim db As Database: Set db = CurrentDb
Dim frm As Form
Dim ctl As Control
Dim varItem As Variant
Dim SQLstr As String
Set frm = Form![frmQuestionaire]![tblQuestions]![tblResponses Subform]
Set ctl = frm!ListRspns
For Each varItem In ctl.ItemsSelected
db.Execute "INSERT INTO tblResponses(Rspns) VALUES ('"" & ctl.
itemdata(varItem) & ""');"
Next varItem
each item selected to its own record. The form I am using is a subform
within a subform. The form name is [frmResponses Subform]. In the form
structure, the main form is frmQuestionaire, the first subform is
tblQuestions, and then tblResponses Subform is a subform within tblQuestions.
When I attempt the code below, I get a Run-time error '2465': Microsoft
Access can't fin the field 'frmQuestionaire' referred to in your expression.
If I change it to jsut the name of the subform [frmResponses Subform] I get
the same error. It errors at the Set frm line.
Any suggestions as to what may be wrong?
Dim db As Database: Set db = CurrentDb
Dim frm As Form
Dim ctl As Control
Dim varItem As Variant
Dim SQLstr As String
Set frm = Form![frmQuestionaire]![tblQuestions]![tblResponses Subform]
Set ctl = frm!ListRspns
For Each varItem In ctl.ItemsSelected
db.Execute "INSERT INTO tblResponses(Rspns) VALUES ('"" & ctl.
itemdata(varItem) & ""');"
Next varItem