试试=删除按钮:
If Tables("表B").count =0
Return
End If
If Tables("表B").current("B1") = Tables("表A").current("A1")
Dim n0,n1,n3 As Integer
Dim n As Integer = Tables("表B").current("B1") '====
n0 = Tables("窗口1_Table1").Compute("max(a1)", "b1 < " & n)
Dim drs0,drs1 As List(Of DataRow)
drs0 = DataTables("窗口1_Table1").Select("[a1] = " & n0)
drs1 = DataTables("窗口1_Table1").Select("[a1] > " & n)
Dim nn As Integer = drs0.count
n1 = DataTables("窗口1_Table1").DataRows.count
'------------------------------------------------------
If n1 > 0 And drs1.count > 0 Or n1 > 0 And drs0.count > 0
Dim dr As DataRow
If nn > 0
dr = DataTables("窗口1_Table1").Find("a1 = " & n0 )
Else
dr = DataTables("窗口1_Table1").Find("a1 > " & n)
End If
n3=dr(("a1") )
'=========
Tables("表A").Current.Delete
DataTables("表B").DeleteFor("B1 = " & Tables(Forms("窗口1").name &"_Table1").Current("a1"))
DataTables("表A").Save
DataTables("表B").Save
DataTables(Forms("窗口1").Name &"_Table1").Load
Forms("窗口1").StopRedraw
Forms("窗口1").Controls("TabControl1").SelectedIndex = 0
Forms("窗口1").ResumeRedraw
'===============
dr = DataTables("窗口1_Table1").Find("a1 = " & n3 )
If dr IsNot Nothing Then
Dim wz As Integer = Tables("窗口1_Table1").FindRow(dr)
If wz >= 0 Then
Tables("窗口1_Table1").Position = wz
End If
End If
ElseIf n1 > 0 And drs1.count = 0 Or n1 > 0 And drs0.count = 0
'=========
Tables("表A").Current.Delete
DataTables("表B").DeleteFor("B1 = " & Tables(Forms("窗口1").name &"_Table1").Current("a1"))
DataTables("表A").Save
DataTables("表B").Save
DataTables(Forms("窗口1").Name &"_Table1").Load
Forms("窗口1").StopRedraw
Forms("窗口1").Controls("TabControl1").SelectedIndex = 0
Forms("窗口1").ResumeRedraw
'===============
End If
MainTable = Tables("窗口1_Table1")
Forms("窗口1").Controls("TabControl1").SelectedIndex = 1
Else
msgbox("两表中没有相同的纪录")
End If
[此贴子已经被作者于2013-3-12 18:10:43编辑过]