[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 209
  • Last Modified:

Delete From A Listview

I want ot delete a record from a database on dblClick from a Listview.

What property am I accessing from the listview...
sKill = listview.WHAT
ie..in a listbox it's list1.text
then I find a match in the mdb and delete it.
If you can how do I clear a listview

Thanks,
Wayne
0
vbWayne
Asked:
vbWayne
  • 4
  • 3
1 Solution
 
samopalCommented:
ListView.SelectedItem.Text

HTH
0
 
vbWayneAuthor Commented:
One piece..is there a clear for a listview.
Ie..listbox = List1.clear

How about a listview. Is there a method?
0
 
rovermCommented:
Deleting the record:

Dim cn As new ADODB.Connection
' set all connection properties here
strSQL = "DELETE FROM MyTable WHERE CheckField = '" & List1.SelectedItem.Text & "'"
cn.Execute s

In this case:
MyTable is your mdb
CheckField is the field to check which record to delete.

You can also use:

strSQL = "DELETE FROM MyTable WHERE CheckField LIKE '" & Trim(List1.SelectedItem.Text) & "%'"

In this case everything like the listbox text will be deleted!

Good luck !

RoverM
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
rovermCommented:
Deleting from a listview:

ListView1.ListItems.Remove (indexnumber)

0
 
vbWayneAuthor Commented:
samopal:

Your answer works for the selection of the item.

I will give you the points though I had hoped for the answer to include how to clear a list view.

Rovern:
Sorry you did all that work and get nothing. I guess my question was vague.
I know how to delete.

What I need is to clear the listview and refill it with refreshed data after I make the deletion.

Wayne
 
0
 
vbWayneAuthor Commented:
I'm told this will work...

ListView1.SubItems.Clear
0
 
vbWayneAuthor Commented:
Actually..the above wont..
this will clear a listview.

ListView1.ListItems.Clear
0
 
rovermCommented:
No problem !

;-) RoverM
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now