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
LVL 1
vbWayneAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

samopalCommented:
ListView.SelectedItem.Text

HTH
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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 Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.