Hi
I've got the following code (following good advice on this forum) but now realise that I need to check for duplicates in the listbox where the NameofEmployee and Department are equal (other columns in the listbox with different values so the records aren't exact matches). I need the Insert Into SQL to be prevented where these fields are equal. The RowSource is a query based on 2 tables. Is there any way of changing the code below to prevent duplicates being selected in the first place? :banghead:
I've got the following code (following good advice on this forum) but now realise that I need to check for duplicates in the listbox where the NameofEmployee and Department are equal (other columns in the listbox with different values so the records aren't exact matches). I need the Insert Into SQL to be prevented where these fields are equal. The RowSource is a query based on 2 tables. Is there any way of changing the code below to prevent duplicates being selected in the first place? :banghead:
Code:
For Each v2 In Me.ListFrom.ItemsSelected
sEmployeeName = Me.ListFrom.Column(2, v2)
sDepartment = Me.ListFrom.Column(3, v2)
dbs.Execute "INSERT INTO EmployeeTbl (nameofemployee,department)VALUES ('" & sEmployeeName & "', '" & sDepartment & "')"
Next v2