RecordSet Do循环有条件或移动到下一个条件 [英] RecordSet Do Loop having condition or move to next condition

查看:68
本文介绍了RecordSet Do循环有条件或移动到下一个条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当满足if语句条件时,我需要一些进程帮助来在do循环中移动next。我打开一个包含3个日期字段和序列号的记录集。我有4个If语句..我的Update语句运行良好,但我无法弄清楚如何处理操作以移动到下一条记录并持续执行动作


1.)如果序列号记录的FirstEmailDate字段未填充,然后填充当前日期和rs.movenext


2.)否则,如果填充了FirstEmailDate并且未填充SecondEmailDate,则填充当前日期进入SecondEmailDate和rs.movenext


3.)否则如果填充了FirstEmailDate和SecondEmailDate字段,则将当前日期填入ThirdEmailDate和rs.movenext


4.)否则,如果填充了FirstEmailDate和SecondEmailDate以及Third EmailDate字段,那么MsgBox已经满足阈值,用户单击ok并且rs.movenext

I need some process help for moving next in a do loop when the if statement condition is met. I am opening a recordset that contains 3 date fields and a serial number. I have 4 If statements.. My Update statements are working well but I cannot figure out how to process the operations to move to the next record and execute the action consistently

1.) If the FirstEmailDate field for the serial number record is not populated then populate the current date and rs.movenext

2.) otherwise if FirstEmailDate is populated and SecondEmailDate is not populated then populate the current date into SecondEmailDate and rs.movenext

3.) otherwise if FirstEmailDate and SecondEmailDate fields are populated then populate the current date into ThirdEmailDate and rs.movenext

4.) otherwise if FirstEmailDate and SecondEmailDate and Third EmailDate fields are populated then MsgBox that threshold has been met, user clicks ok and rs.movenext

展开 | 选择 | Wrap | 行号

推荐答案

MitchR,


你应该能够简单地删除 rs0.MoveNext 的前三次迭代。只有满足特定条件时才会执行查询。完成所有检查后,只需移动到下一条记录。
MitchR,

You should be able to simple remove the first three iterations of rs0.MoveNext. The queries will only execute if the particular criteria are met. After all the checking, then just move to the next record.


我的第一条评论是你应该总是尝试缩进你的代码。非缩进代码非常难以阅读和使用。唯一比非缩进代码更糟糕的是缩进的代码 - 但不是以任何一致的方式。这是一场灾难,如果可能的话应该避免。这使得它非常难以使用。我下面的缩进将从左侧开始,但您可能需要进一步缩进以适应程序。


所以,我现在假设你的部分'虽然我不想在你的实际代码中发布,因为我不想浪费时间来处理你应该已经介绍过的琐碎细节。


NB。显然你发布的内容不可行。这可能部分或完全是由于您遗漏了您认为无关的部分。作为一般规则,即使您只包含部分代码,您包含的内容也应该是至少编译的代码。发布未编译的代码是浪费每个人的时间,专家可能会对那些不首先确保他们发布的内容同时复制/粘贴的成员感到不满编译的代码。


NB。我已经建议了一些符合您解释的代码。你现有的代码引用了一个不包含在该解释中的表格,所以我希望我没有浪费我的时间,因为你没有准确地解释情况。但是,你的解释确实有意义,而你的代码却没有,所以这就是我的用处。
My first comment would be that you should always try to indent your code. Non-indented code is very difficult to read and work with. The only thing worse than non-indented code is code that is indented - but not in any consistent way. That''s a disaster and should be avoided if you possibly can. It makes it extraordinarily difficult to work with. My indenting below will start from the left but you will probably have to indent it further to fit within a procedure.

So, I''ll assume for now that the the parts you''ve not posted are nevertheless in your actual code somewhere as I don''t want to waste time with trivial details you should have covered already.

NB. Obviously what you''ve posted can''t possibly work. This may be partly or completely due to your leaving out parts that you consider irrelevant. As a general rule, even if you include only a part of the code, what you include should be code that at least compiles. Posting uncompiled code is a waste of everyone''s time and experts are liable to get upset with members that don''t first ensure that what they''ve posted is both Copy/Pasted and is from code that compiles.

NB. I''ve suggested some code that matches your explanation. Your existing code references a Form that isn''t included in that explanation so I hope I haven''t been wasting my time based on your not explaining the situation accurately. However, your explanation does make sense, while your code doesn''t, so that''s what I''ve gone with.
展开 | 选择 | 换行 | 行号


您是否有理由需要在记录集而不是更新查询中执行此操作?
Is there a reason you need to do this in a recordset instead of an update query?


这篇关于RecordSet Do循环有条件或移动到下一个条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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