Skip Bisconer
Who Me?
- Local time
- Today, 05:47
- Joined
- Jan 22, 2008
- Messages
- 285
This code seems to give me an incorrect result with the rs!Position = Me.Employee.Column(3) in the below code. It gives one of the Position names for all the employees selected. All the others give me the correct results except for that one
Code:
Private Sub cmdAddRecord_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("tblTrainingLog", dbOpenDynaset, dbAppendOnly)
'make sure a selection has been made
If Me.Employee.ItemsSelected.Count = 0 Then
MsgBox "Must select at least 1 employee"
Exit Sub
End If
'add selected value(s) to table
Set ctl = Me.Employee
For Each varItem In ctl.ItemsSelected
rs.AddNew
rs!EmpID = ctl.ItemData(varItem)
rs!CWSPolicy = Me.CWSPolicy
rs!Title = Me.Title
rs!DateTrained = Me.DateTrained
rs!Intv = Me.Intv
rs!RetrainDate = Me.RetrainDate
[COLOR=red]rs!Position = Me.Employee.Column(3)[/COLOR]
rs.Update
Next varItem
cmbPolicylookup = ""
Title = ""
Intv = ""
DateTrained = ""
RetrainDate = ""
DoCmd.Close
DoCmd.OpenForm "frmUpdateTrainingLog"
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