G
Guest
Hello,
In my form, I have a text box for business line (txtSelBusLine) and a
multiple selection list box (lstAuth_Ex) for stock exchanges. List box is
pulling data from a table (Parent_Child_Auth_EX) where it stores which
business line has what exchanges.
What I want to do is user will select items they want to delete from
lstAuth_Ex, click a button and the selected items belongs to the business
line will be deleted from the Parent_Child_Auth_EX table
I have these code, and have step through them, everything seems to run fine,
but the selected items are still not deleted from the table.
Can someone please tell me what's wrong? My sql statement or the logic?
Private Sub cmdDelEx_Click()
Dim db As Database
Dim rstCur As Recordset
Dim VarSelectEx As Variant
Dim SelectEx, DelSQL As String
DelSQL = "DELETE Parent_Child_Auth_EX.Parent_Child_Name,
Parent_Child_Auth_EX.Auth_Ex " _
& "FROM Parent_Child_Auth_EX " _
& "WHERE (((Parent_Child_Auth_EX.Parent_Child_Name)='" &
Me.txtSelBusLine.Value & "') " _
& "AND ((Parent_Child_Auth_EX.Auth_Ex)='" & SelectEx & "'));"
For Each VarSelectEx In Me.lstAuth_Ex.ItemsSelected
SelectEx = Me.lstAuth_Ex.ItemData(VarSelectEx)
DoCmd.RunSQL DelSQL
Next
Me.lstAuth_Ex.Requery
End Sub
In my form, I have a text box for business line (txtSelBusLine) and a
multiple selection list box (lstAuth_Ex) for stock exchanges. List box is
pulling data from a table (Parent_Child_Auth_EX) where it stores which
business line has what exchanges.
What I want to do is user will select items they want to delete from
lstAuth_Ex, click a button and the selected items belongs to the business
line will be deleted from the Parent_Child_Auth_EX table
I have these code, and have step through them, everything seems to run fine,
but the selected items are still not deleted from the table.
Can someone please tell me what's wrong? My sql statement or the logic?
Private Sub cmdDelEx_Click()
Dim db As Database
Dim rstCur As Recordset
Dim VarSelectEx As Variant
Dim SelectEx, DelSQL As String
DelSQL = "DELETE Parent_Child_Auth_EX.Parent_Child_Name,
Parent_Child_Auth_EX.Auth_Ex " _
& "FROM Parent_Child_Auth_EX " _
& "WHERE (((Parent_Child_Auth_EX.Parent_Child_Name)='" &
Me.txtSelBusLine.Value & "') " _
& "AND ((Parent_Child_Auth_EX.Auth_Ex)='" & SelectEx & "'));"
For Each VarSelectEx In Me.lstAuth_Ex.ItemsSelected
SelectEx = Me.lstAuth_Ex.ItemData(VarSelectEx)
DoCmd.RunSQL DelSQL
Next
Me.lstAuth_Ex.Requery
End Sub