Sorry, I didn't notice before, but the reference to the control on the
subform is wrong.
To refer to a control on a subform from the parent form, you use:
Me!NameOfSubformControlOnParent.Form!NameOfControlOnSubform
Depending on how you added the subform to the parent, the name of the
subform control may not be the same as the name of the form being used as a
subform. However, try Me!sfrmStudent.Form!StudentID first.
However, now that I look at your entire code (all I was looking at before
was the SQL), what are you trying to do?
You're looping through a recordset, but you're referring to controls on a
form. That means you're going to get the exact same SQL every time.
If you're trying to pick up values from the recordset, you need to refer to
the recordset.
If you're trying to pick up values from the subform's recordset, you'll need
to refer to it correctly:
rst = Me!sfrmStudent.Form.RecordsetClone
(assuming, as above, that the name of the subform control is sfrmStudent)
and you probably want
strSQL = "Insert Into TempStudent_Task(StudentID, TaskID)" & _
"VALUES('" & rst!StudentID & "', '" & Me!TaskID & "')"