Private Sub cmdAddTraining_Click()
[COLOR="Olive"][COLOR="Green"]'This will add a training record for each person in the right-hand list on screen.
[/COLOR][/COLOR]
    Dim nResumeCount     As Integer
    Dim iEmp             As Integer
    Dim dDateTaken       As Date
    Dim sExpires         As Variant
    Dim iRev             As Integer
    Dim iCourId          As Integer
    Dim iHeadId          As Integer
    Dim iSupp            As Integer
    Dim iSkill           As Integer
    Dim ctlList          As Control
    Dim varItem          As Variant
    Dim iRow             As Integer
    Dim iTrain           As Integer
    Dim iUpdCnt          As Integer
    Dim sSql             As String
    Dim dEntered         As Date
    Dim iResp            As Integer
    Dim db               As DAO.Database
    If IsNull(Me.cmbSupplier) Then
        MsgBox "Please select a supplier", vbExclamation, "No Supplier error!"
        Exit Sub
    End If
    iResp = MsgBox("You are about to add training records for all the employees in the green list." & vbCrLf & "Are you certain all the information is correct?", vbOKCancel, "Course Update!")
    If iResp = vbCancel Then Exit Sub
    Set db = CurrentDb
[COLOR="green"]    'Set up values for inserted records[/COLOR]
    dDateTaken = Me.txtDateTaken
    iRev = Me.txtRevision
    iCourId = Me.cmbSubCorID
    iHeadId = Me.cmbCHeadID
    iSupp = Nz(Me.cmbSupplier, 0)
    dEntered = Date
    iSkill = Me.txtSkillLevel
    iTrain = Nz(Me.cmbTrainer, 0)
    iUpdCnt = lstEmpSelect.ListCount
    If Not IsNull(Me.txtExpires) Then
        sExpires = "#" & Format(Me.txtExpires, "mm/dd/yyyy") & "#"
    Else
        sExpires = "Null"
    End If
[COLOR="green"]    'Loop through selected listbox items[/COLOR]
    For iRow = 0 To lstEmpSelect.ListCount - 1
        iEmp = lstEmpSelect.Column(0, iRow)
        sSql = "INSERT INTO [TRA_Emp_Record] (EmpID, SubCourse_ID, Date_Entered, Date_Taken, "
        sSql = sSql & "[Expiry_Date], Passed, SkillLevel, InternalTrainer, CourseHeadID, SupplierID, Revision, SignOff) "
        sSql = sSql & "VALUES (" & iEmp & ", " & iCourId & ", #" & Format(dEntered, "mm/dd/yyyy") & "#, #" & Format(dDateTaken, "mm/dd/yyyy") & "#, "
        sSql = sSql & "" & sExpires & ", 1, " & iSkill & ", " & iTrain & ", " & iHeadId & ", " & iSupp & ", " & iRev & ", 0); "
        db.Execute sSql, dbSeeChanges
    Next iRow
    Set db = Nothing
    MsgBox "You have added " & iUpdCnt & " training records to the system.", vbInformation, "Update sucessful"
    
[COLOR="green"]    ' After completion call the routine to remove all the selected entries and reset the main list[/COLOR]
    Call cmdRemAll_Click
    Exit Sub