首页上一页 1 下一页尾页 5 条记录 1/1页
删除行定位书签的问题
发表在VB答疑区
2007-10-30
是否精华
是
否
版块置顶:
是
否
老师,我用下面的代码[_[font|_|size=4]_]删除最后一行刷新显示时为什么书签总是显示在DATAGRID的第一行呢[_[/font]_],如果删除的是其它行,则刷新后书签就能自动移到删除的下一行。该如何解决呢?请指导,谢谢!
Private Sub Cmd_Del_Click()
Dim mybookmark As Variant
On Error Resume Next
Adodc2.RecordSource = "select * from 表 where clbm= + RTrim(DataGrid2.Columns(1).Text) + "
Adodc2.Refresh
If Adodc2.Recordset.RecordCount > 0 Then
aa = MsgBox("你确定要删除该记录吗?", vbYesNo, "提示")
If aa = vbYes Then
Adodc2.Recordset.Delete
If Adodc2.Recordset.EOF Then
Adodc2.Recordset.MoveLast
mybookmark = DataGrid2.Bookmark
Else
Adodc2.Recordset.MoveNext
mybookmark = DataGrid2.Bookmark
End If
Adodc2.Refresh
End If
End If
Adodc2.RecordSource = "select c.xh,c.clbm,b.clmc,b.clxh,b.cldw,c.clde,c.clnote,c.clcj from 表 c,cl_bm b where c.clbm=b.clbm and c.clcj= + Combo3.Text + "
Adodc2.Refresh
Set DataGrid2.DataSource = Adodc2.Recordset
DataGrid2.Bookmark = mybookmark
End Sub
Private Sub Cmd_Del_Click()
Dim mybookmark As Variant
On Error Resume Next
Adodc2.RecordSource = "select * from 表 where clbm= + RTrim(DataGrid2.Columns(1).Text) + "
Adodc2.Refresh
If Adodc2.Recordset.RecordCount > 0 Then
aa = MsgBox("你确定要删除该记录吗?", vbYesNo, "提示")
If aa = vbYes Then
Adodc2.Recordset.Delete
If Adodc2.Recordset.EOF Then
Adodc2.Recordset.MoveLast
mybookmark = DataGrid2.Bookmark
Else
Adodc2.Recordset.MoveNext
mybookmark = DataGrid2.Bookmark
End If
Adodc2.Refresh
End If
End If
Adodc2.RecordSource = "select c.xh,c.clbm,b.clmc,b.clxh,b.cldw,c.clde,c.clnote,c.clcj from 表 c,cl_bm b where c.clbm=b.clbm and c.clcj= + Combo3.Text + "
Adodc2.Refresh
Set DataGrid2.DataSource = Adodc2.Recordset
DataGrid2.Bookmark = mybookmark
End Sub