设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 1467|回复: 2
打印 上一主题 下一主题

[表] 求教:比较两个表是否有相同记录

[复制链接]
1#
发表于 2009-6-23 18:05:09 | 显示全部楼层
1# bd4acw

Private Sub 比较_Click()
Dim rst As ADODB.Recordset
Dim strSQL As String
'-----
strSQL = "SELECT A.OrderId FROM OrderList AS A INNER JOIN kdjl AS B " _
    & "ON A.OrderId=B.OrderId ORDER BY A.OrderId"
Set rst = New ADODB.Recordset
    With rst
        .ActiveConnection = CurrentProject.Connection
        .CursorType = adOpenStatic
        .LockType = adLockOptimistic
        .Source = strSQL
        .Open
    End With
    strSQL = ""
    If Not rst.EOF Then
        Do Until rst.EOF
            If strSQL = "" Then
                strSQL = rst(0)
            Else
                strSQL = strSQL & "," & rst(0)
            End If
            rst.MoveNext
        Loop
        MsgBox strSQL & "存在重复!"
    End If
    rst.Close
Set rst = Nothing
End Sub

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-5-21 00:25 , Processed in 0.070351 second(s), 24 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表