Hello,
i'm kind of new to working with VBA Access and i am experiencing some problem.
i have a table where the user can save labels. then i have a listbox where the user can see which labels are saved with his username.
i also have the option for the user to deleted records that he doesn't want to print.
now i have a code to delete the records. It deletes the selected items from the table. but it doesn't quite work ok. When i have deleted the selected items. the items that are still in the listbox aren't correct. it delete a record which i haven't selected.
naamloos.jpg is a screenshot before i delete the selected items.
after.jpg is a screenshot after i have deleted the selected items.
as you can see it didn't deleted the items i selected. if you look at naamloos.jpg you see that i didn't selected one hpl-40 and one hpl-131.
so those 2 should still be in the listbox after i press delete selected.
but if you look at after.jpg you can see that there are two hpl-131.
this is the code i use.
can somebody please help me with this?
ilse
i'm kind of new to working with VBA Access and i am experiencing some problem.
i have a table where the user can save labels. then i have a listbox where the user can see which labels are saved with his username.
i also have the option for the user to deleted records that he doesn't want to print.
now i have a code to delete the records. It deletes the selected items from the table. but it doesn't quite work ok. When i have deleted the selected items. the items that are still in the listbox aren't correct. it delete a record which i haven't selected.
naamloos.jpg is a screenshot before i delete the selected items.
after.jpg is a screenshot after i have deleted the selected items.
as you can see it didn't deleted the items i selected. if you look at naamloos.jpg you see that i didn't selected one hpl-40 and one hpl-131.
so those 2 should still be in the listbox after i press delete selected.
but if you look at after.jpg you can see that there are two hpl-131.
this is the code i use.
Code:
Dim Response As Integer
Response = MsgBox(prompt:="Are you sure you want to delete the selected labels?", Buttons:=vbYesNo)
For i = 0 To Me.list_labeloverview.ItemsSelected.Count - 1
Dim LabelName As String
Dim h_mySQL As String
Dim ChosenName As String
Dim h_Queryname As String
Dim h_qdf As DAO.QueryDef
Dim h_rs As DAO.Recordset
LabelName = Me.list_labeloverview.ItemData(Me.list_labeloverview.ItemsSelected.item(i))
Set h_rs = CurrentDb.OpenRecordset("Generate_Labels")
With h_rs
If Response = vbYes Then
.Delete
Else
.Close
End If
End With
Next
UpdateGetLabels
can somebody please help me with this?
ilse