hello - I have code that should delete records based on matching one table field (BinID) with a combobox (Me!cboBin.Column(0)) AND matching another field (MemID) with a listbox selection(Me!lstMem.Column(0, varItem)). My problem is the records are never deleted. The '.delete' code line is always skipped when I step through code.
Typical data from the 'debug' line is shown below. I expected deletions to occur in the 2nd line and the 10th line, but no deletions occur. What am I missing?
3 8 43
4 3 43
4 4 43
4 5 43
NullNull 43
4 1 43
3 8 45
4 3 45
4 4 45
4 5 45
NullNull 45
4 1 45
Thanks for taking the time to help
Vicky
Code:
'if BinID AND MemID aleady in tblBinMem, then delete it
Set db = CurrentDb()
Set rs = db.OpenRecordset("tblBinMem", dbOpenDynaset)
For Each varItem In Me!lstMem.ItemsSelected
With rs
Do While Not .EOF
Debug.Print !BinID; !MemID, Me!cboBin.Column(0); Me!lstMem.Column(0, varItem)
If !BinID = Me!cboBin.Column(0) And !MemID = Me!lstMem.Column(0, varItem) Then
.Delete
Exit Do
End If
.MoveNext
Loop
.MoveFirst
End With
Next varItem
Typical data from the 'debug' line is shown below. I expected deletions to occur in the 2nd line and the 10th line, but no deletions occur. What am I missing?
3 8 43
4 3 43
4 4 43
4 5 43
NullNull 43
4 1 43
3 8 45
4 3 45
4 4 45
4 5 45
NullNull 45
4 1 45
Thanks for taking the time to help
Vicky