Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

datagrid in vb

Status
Not open for further replies.

ishikha

Programmer
Mar 22, 2002
36
0
0
IN
hi friends,

i want to delete the record in between the data grid.can u suggest me how i will be able to do it.
i am sending the code

Private Sub delete_Click()
DataGrid1.AllowDelete = True
DataGrid1.AllowUpdate = True
If AdoRs.EOF Then
MsgBox "No more records in the file", , ""
Exit Sub
End If
AdoRs.delete

If Not AdoRs.EOF Then
AdoRs.Update
AdoRs.MoveNext
End If
DataGrid1.Refresh
End Sub

by using this code i am able to delete the first record in the database everytime but i want that as i select some record in between the datagrid with the record selector and press delete it will delete that record from the database

please suggest me some sol.

regards
ishikha
 
try this

Private Sub delete_Click()
Dim vBm As Variant
If DataGrid1.ApproxCount > 0 Then
For Each vBm In DataGrid1.SelBookmarks
AdoRs.Recordset.Bookmark = vBm
AdoRs.Recordset.Delete
AdoRs.Recordset.Update
Next
End If
DataGrid1.Refresh
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top