Deleting items from an unbound listbox and table

ccox

Registered User.
Local time
Today, 02:39
Joined
Dec 27, 2005
Messages
32
I have a combo box that inserts data into an unbound list box and table. This works great but I am having trouble with the deletion part. I want to be able to dbl click on the item in the item list and delete it from both the list box and table. Currently, my code is deleting ALL items, not just the one item I want to get rid of. Any ideas would be most appreciated :)
This is what I have for the deletion code:

Private Sub List92_DblClick(Cancel As Integer)
DoCmd.SetWarnings False
sql2 = "delete from PROFILE_Industry where "
sql2 = sql2 & "profile_id = " & Me!Profile_ID
sql2 = sql2 & " And Industry_focus = '" & Me!List92.Value & "';"
DoCmd.RunSQL (sql2)
Me.Refresh
DoCmd.SetWarnings True
End Sub
 
Have you displayed your sql2 variable to verify the sql is proper (it looks like it should be) and is picking up the proper variable values and has them formatted correctly?
 
I'm not sure I understand the question so I apologize. Should I have declared a variable with a DIM stmt
 
For any others interested, here is the code to solve this issue:
Private Sub List92_DblClick(Cancel As Integer)
DoCmd.SetWarnings False
sql1 = "Delete from Profile_Industry where Profile_ID = " & Me!Profile_ID & " And Industry_Type = '"
sql1 = sql1 & List92.Column(0) & "';"
DoCmd.RunSQL (sql1)
Me.Refresh
DoCmd.SetWarnings True
End Sub
 

Users who are viewing this thread

Back
Top Bottom