AnneYourPointIs
asked on
Multi Select List delete records from table
Hello,
I have a multi select list box that I'm appending records to 1 table but I want to delete records from another table. I'm not getting any errors in the code below. It Appends records to my table tblOOSInventory but it's not deleting the records in my tblItemsIssued. I'm not sure if there is an issue in my delete statement or not.
Any help would greatly be appreciated.
Thanks,
Lisa
Dim strItems As String
Dim intItem, sql, SQL2
With Me.List2
For intItem = 0 To .ListCount - 1
If .Selected(intItem) Then
strItems = strItems & .Column(0, intItem) & "," & _
.Column(1, intItem) & "," & _
Chr(39) & .Column(2, intItem) & Chr(39) & "," & _
Chr(39) & .Column(3, intItem) & Chr(39) & "," & _
Chr(39) & .Column(4, intItem) & Chr(39) & "," & _
Chr(39) & .Column(5, intItem) & Chr(39)
sql = "Insert into tblOOSInventory(InvIssID, EmpID, IssBC, InvType, Size, ILOC) values (" & strItems & ")"
Currentdb.Execute sql
strItems = ""
SQL2 = "Delete * FROM tblItemsIssued Where InvIssID= "
SQL2 = SQL2 & List2.Selected(intItem) & ";"
Currentdb.Execute SQL2
End If
Next
End With
I have a multi select list box that I'm appending records to 1 table but I want to delete records from another table. I'm not getting any errors in the code below. It Appends records to my table tblOOSInventory but it's not deleting the records in my tblItemsIssued. I'm not sure if there is an issue in my delete statement or not.
Any help would greatly be appreciated.
Thanks,
Lisa
Dim strItems As String
Dim intItem, sql, SQL2
With Me.List2
For intItem = 0 To .ListCount - 1
If .Selected(intItem) Then
strItems = strItems & .Column(0, intItem) & "," & _
.Column(1, intItem) & "," & _
Chr(39) & .Column(2, intItem) & Chr(39) & "," & _
Chr(39) & .Column(3, intItem) & Chr(39) & "," & _
Chr(39) & .Column(4, intItem) & Chr(39) & "," & _
Chr(39) & .Column(5, intItem) & Chr(39)
sql = "Insert into tblOOSInventory(InvIssID, EmpID, IssBC, InvType, Size, ILOC) values (" & strItems & ")"
Currentdb.Execute sql
strItems = ""
SQL2 = "Delete * FROM tblItemsIssued Where InvIssID= "
SQL2 = SQL2 & List2.Selected(intItem) & ";"
Currentdb.Execute SQL2
End If
Next
End With
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER