Hi all,

I`m new to this group, I have been recommended I come here from the 
Word VBA group. I wonder if anyone can help, below is the message I 
posted to the Word VBA group, not sure if it will make sense over 
here so feel free to ask.....

I was just wondering if anyone could give me any suggestions of
where to look or any help on deleting records from databases.

Basically I am populating ListBox1 with data from "TableFolder" in
an access database through my word VB.

I want to then be able to highlight an item in ListBox1 and then
delete this from the database and from the listbox.

I have managed to delete the item in ListBox1, and
then delete a record from the database. The problem is that the
record deleted from the database is simply the first record there,
and not the record highlighted in the listbox.

Does anyone have any suggestions please? I`ve been searching the web
for days now and am getting really confused with the whole thing!

Thanks in advance for any help anyone can give.

The code I have so far is below (by the way I`ve assumed that I`ve
already populated the listbox.)

*******************************************
Private Sub CommandButtonDelete_Click()

Dim vConnection As New ADODB.Connection
Dim vRecordSetFolder As New ADODB.Recordset

Set vRecordSetFolder = New ADODB.Recordset

vConnection.ConnectionString = "data source=G:\FilingLabel.mdb;" & _
"Provider=Microsoft.Jet.OLEDB.4.0;"

vConnection.Open

vRecordSetFolder.Open "TableFolder", vConnection, adOpenKeyset,
adLockOptimistic


vRecordSetFolder.Delete
ListBox1.RemoveItem ListBox1.ListIndex

End Sub
**************************************************






---------------------------------------------------------------------    
 Home       : http://groups.yahoo.com/group/active-server-pages
---------------------------------------------------------------------
 Post       : [email protected]
 Subscribe  : [EMAIL PROTECTED]
 Unsubscribe: [EMAIL PROTECTED]
--------------------------------------------------------------------- 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/active-server-pages/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to