|
似乎有点明白
1 。暂且称,表1为a,表2为b,字段均为start ,end
2. 新建一个窗体,上面放一个按钮command2,按钮事件如下,(你自己测试一下)
Private Sub Command2_Click()
Dim rs As New ADODB.Recordset
Dim rst As New ADODB.Recordset
Dim S, S1, E, E1 As Long
rs.Open "a", CurrentProject.Connection, adOpenKeyset, adLockReadOnly
Do While Not rs.EOF
S = rs("start")
E = rs("end")
rst.Open "b", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
rs.MoveNext
S1 = rs("start")
E1 = rs("end")
If E + 1 = S1 Then
rst.AddNew
rst("star") = S
rst("end") = E1
rst.Update
rst.Close
End If
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Set rst = Nothing
End Sub |
|