I've added your sample db code and renamed objects for my database.
Code:
Private Sub btnEnroll_Click()
Dim strSQL As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim ctl As Control
Dim varItem As Variant
On Error GoTo ErrorHandler
Set db = CurrentDb()
Set rs = db.OpenRecordset("tblClassAttendance", dbOpenDynaset, dbAppendOnly)
'make sure a selection has been made
If Me.lstStudentIDs.ItemsSelected.Count = 0 Then
MsgBox "Must select at least 1 student"
Exit Sub
End If
If Not IsNumeric(Me.SessionID) Then
MsgBox "Must enter numeric Session ID"
Exit Sub
End If
'add selected value(s) to table
Set ctl = Me.lstStudentIDs
For Each varItem In ctl.ItemsSelected
rs.AddNew
rs!EmpID = ctl.ItemData(varItem)
rs!OtherValue = Me.SessionID
rs.Update
Next varItem
ExitHandler:
Set rs = Nothing
Set db = Nothing
Exit Sub
ErrorHandler:
Select Case Err
Case Else
MsgBox Err.Description
DoCmd.Hourglass False
Resume ExitHandler
End Select
End Sub
Should I now be able to execute it? I still don't see the SQL "string" defined or called anywhere.