如何比较访问vba中的记录集 [英] How to compare recordsets in access vba

查看:78
本文介绍了如何比较访问vba中的记录集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我想比较两个记录集。第一个rs1有随机记录。第二个rs2具有这些记录的标准值。最初,我希望获取每个记录,看看它们是否与第二个记录集中的标准值集匹配。每个记录集中有四个字段需要进行比较,所有四个字段必须匹配。


我只需要在循环中提供一些帮助。我正在尝试将不匹配的记录写入excel文件。这是我到目前为止

Hi,

I am trying to compare two recordsets. the first rs1 has random records. The second rs2 has the standard values for those records. Initially I am looking to take each of the records and see if they match with the standard set of values in the second recordset. There are four fields in each record set to be compared and all four must match.

I just need some help in the loop. I am trying to write the non matching records to an excel file. Here is what I have so far

展开 | 选择 | Wrap | 行号

推荐答案

@atksamy

这是什么意思?我不知道你在这里想说什么。
@atksamy
What does that mean? I have no idea what you''re trying to say here.


如果我理解正确,你打开2个记录集,你就开始比较rst1中的第一个记录到第一个记录集记录在rst2。

这不是一个好主意,因为您假设记录在两个表/记录集中以完全相同的顺序存在。仅仅因为它可能是A。在B之前在C之前在rst1中并不意味着它在rst2中是相同的,它可以是C。在A之前在B之前在rst2。


这就是你在做什么?


此外,如果你包括你如何定义你的rst1和rst2,它可能会有所帮助。


-AJ
If I understand this correctly, you are opening 2 record sets and you just start comparing the first record in rst1 to the first record in rst2.
This is not a good idea because you are assuming that the records exist in the exact same order in both tables/record sets. Just because it may be "A" before "B" before "C" in rst1 doesn''t mean it will be the same in rst2, it could be "C" before "A" before "B" in rst2.

Is this what you are doing?

Also, it may help if you included how you defined your rst1 and rst2.

-AJ


迭代记录集以查找匹配项的代码部分可以很好地替换为sql内部联接。

为什么要支付更多?


亲切的问候,

Fish。
The part of your code which iterates recordsets to find matches could be well replaced with sql inner join.
Why pay more?

Kind regards,
Fish.


这篇关于如何比较访问vba中的记录集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆