I’m getting a run-time error and I’m not sure what’s causing it. See the picture for the error and the form it’s erring on.
This is the code behide the left arrow (removes approved names from list).
====================================================================
Private Sub cmdRemoveEmployee_Click()
Dim rs As New ADODB.Recordset
Dim ListCol0 As String
Dim ListCol1 As String
Dim frm As Form
Dim ctl As Control
Dim varitm As Variant
Dim intI As Integer
Set frm = Forms!subfrmApprovedInstallations
Set ctl = frm!lstApprovedEmployees
rs.Open “tblApprovedInstallations2”, CurrentProject.Connection, adOpenKeyset, adLockOptimistic, adCmdTableDirect
With rs
For Each varitm In ctl.ItemsSelected
For intI = 0 To ctl.ColumnCount – 3
ListCol0 = Me.lstApprovedEmployees.Column(0)
ListCol1 = Me.lstApprovedEmployees.Column(1)
.Index = “PrimaryKey” ‘THE ERROR APPEARS ON THIS LINE
.Seek Array(ListCol1, ListCol0), adSeekFirstEQ
If (Not .BOF And Not .EOF) Then
.Delete
End If
Next intI
Next varitm
.Close
End With
Set rs = Nothing
Me.lstApprovedEmployees.Requery
Me.lstAvailableEmployees.Requery
End Sub
=============================================================================
The error appears on line “.Index = “PrimaryKey””. On the tblApprovedInstallations2 table I have an index set called PrimaryKey that uses the EmployeeNumber field and the SoftwareProductID field. The error appears when I have more than one item highlighted in the Approved listbox and click the button. I don’t get any error when I do one by one.
Any ideas?
Thanks sarah