Pauline123
Registered User.
- Local time
- Today, 21:52
- Joined
- Apr 1, 2013
- Messages
- 69
Hey hope someone can help.
I have an unbound form that I have a multi-select list and unbound fields to enter data into the Theory Training Table.
I thought I had got the bugs out but now keep getting the "Object Doesn't Support..." error message.
The details are:
Forms Name: TheoryTraining
Unbound List Box Name: EmployeeList (EmployeeNo)
Three Combo Boxes: TxtTheoryCategory / TxtTheoryCourse / TxtProvider
VBA Code on Command Button - Click:
Private Sub Command38_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("TheoryTrainingTB", dbOpenDynaset, dbAppendOnly)
'make sure a selection has been made
If Me.EmployeeList.ItemsSelected.Count = 0 Then
MsgBox "You Must Select an Employee"
Exit Sub
End If
'add selected value(s) to table
Set ctl = Me.EmployeeList
For Each varItem In ctl.ItemsSelected
rs.AddNew
rs!EmployeeNo = ctl.ItemData(varItem)
rs!TheoryStartDate = Me.txtTheoryStartDate
rs!TheoryExpiryDate = Me.txtTheoryExpiryDate
rs!TheoryCategory = Me.txtTheoryCategory
rs!TheoryCourse = Me.txtTheoryCourse
rs!Provider = Me.txtProvider
rs!ThCertificateNo = Me.txtThCertificateNo
rs!TheoryNotes = Me.txtTheoryNotes
rs!TheoryRenew = Me.txtTheoryRenew
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
When I have got it to work it enters a row in the table with the training details, then a further row / rows with the Employee Number. I need the training and the Employee number to be entered on to the same row - can anyone help - Thanks Pauline
I have an unbound form that I have a multi-select list and unbound fields to enter data into the Theory Training Table.
I thought I had got the bugs out but now keep getting the "Object Doesn't Support..." error message.
The details are:
Forms Name: TheoryTraining
Unbound List Box Name: EmployeeList (EmployeeNo)
Three Combo Boxes: TxtTheoryCategory / TxtTheoryCourse / TxtProvider
VBA Code on Command Button - Click:
Private Sub Command38_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("TheoryTrainingTB", dbOpenDynaset, dbAppendOnly)
'make sure a selection has been made
If Me.EmployeeList.ItemsSelected.Count = 0 Then
MsgBox "You Must Select an Employee"
Exit Sub
End If
'add selected value(s) to table
Set ctl = Me.EmployeeList
For Each varItem In ctl.ItemsSelected
rs.AddNew
rs!EmployeeNo = ctl.ItemData(varItem)
rs!TheoryStartDate = Me.txtTheoryStartDate
rs!TheoryExpiryDate = Me.txtTheoryExpiryDate
rs!TheoryCategory = Me.txtTheoryCategory
rs!TheoryCourse = Me.txtTheoryCourse
rs!Provider = Me.txtProvider
rs!ThCertificateNo = Me.txtThCertificateNo
rs!TheoryNotes = Me.txtTheoryNotes
rs!TheoryRenew = Me.txtTheoryRenew
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
When I have got it to work it enters a row in the table with the training details, then a further row / rows with the Employee Number. I need the training and the Employee number to be entered on to the same row - can anyone help - Thanks Pauline