hello gurus
I'm sure I'm missing something simple, but I just can't see my error. I have a form (frmBinMonth) bound to (qryBinMem) that gets values from (tblBinMem). The form has a combobox (cboBin), a multi-select listbox (lstMembers), and a button (cmdAdd). When I click cmdAdd, I want to append records based on the combobox's value and the listbox's selections. But, I only want to add the records that have no matching records in tblBinMem already. My code always appends records, even if they already have matches. Any ideas? I'm suspecting the FindFirst criteria, but I'm not sure.
Thanks for any help
Vicky C
I'm sure I'm missing something simple, but I just can't see my error. I have a form (frmBinMonth) bound to (qryBinMem) that gets values from (tblBinMem). The form has a combobox (cboBin), a multi-select listbox (lstMembers), and a button (cmdAdd). When I click cmdAdd, I want to append records based on the combobox's value and the listbox's selections. But, I only want to add the records that have no matching records in tblBinMem already. My code always appends records, even if they already have matches. Any ideas? I'm suspecting the FindFirst criteria, but I'm not sure.
Code:
'if MemID/BinNum combo NOT already in tblBinMem, append it
Set db = CurrentDb()
Set rs = db.OpenRecordset("tblBinMem", dbOpenDynaset, dbAppendOnly)
For Each varItem In Me!lstMembers.ItemsSelected
With rs
.FindFirst "BinID = " & Me!cboBin.Column(0) & " AND MemID = " & Me!lstMembers.Column(0, varItem)
If .NoMatch Then
.AddNew
!MemID = Me!lstMembers.Column(0, varItem)
!BinID = Me!cboBin.Column(0)
.Update
Else
MsgBox "Record already exists."
End If
End With
Next varItem
Thanks for any help
Vicky C