Gasman
Enthusiastic Amateur
- Local time
- Today, 13:44
- Joined
- Sep 21, 2011
- Messages
- 17,473
Well for a start you have not put the create email within the loop, which is the base of your problem from the start, in my view. 
Walk though your code with F8 and hover or debug.print your variables/fields. MSGBOX is too interactive for this in my view.
No need to test for EOF before sending a message, you have a loop doing that.
Just move next, however until you create a new email within the loop, the rest is moot.
I gave you the basics. Start from that and then add your complexity.
Personally I see no need to movelast and move first unless you need to know the exact recordcount?
I would myself not even bother as if no records exist your Do Until rs.EOF will be true and none of the email code will be run.
See if Gina's code is easier to understand.
www.access-diva.com
Walk though your code with F8 and hover or debug.print your variables/fields. MSGBOX is too interactive for this in my view.
No need to test for EOF before sending a message, you have a loop doing that.
Just move next, however until you create a new email within the loop, the rest is moot.
I gave you the basics. Start from that and then add your complexity.
Personally I see no need to movelast and move first unless you need to know the exact recordcount?
I would myself not even bother as if no records exist your Do Until rs.EOF will be true and none of the email code will be run.
See if Gina's code is easier to understand.
Access Diva Looping Records to Send eMail
Access-Diva provides custom databases using Microsoft Access utilizing SQL Server when called for.
Last edited: