loop through records

Dylan Snyder

Registered User.
Local time
Today, 16:23
Joined
Dec 31, 2007
Messages
89
I have to make a form that extracts out to multiple buyers for our company. What I have been doing in the past is making the form based off of a table with a record for each buyer along with the email address. There would be a button for each record and the user would click on the button, thereby selecting that record and the VBA would use the current emailaddress to send email.

Question is this: is there a way to skip all this? Is there a way to loop through each record in a table, send the email, and then go to the next record? - and then maybe most importantly, stop after the end of the table?
 
Yes. Search the forum for ado or dao recordsets. Then post back if things are still unclear - :)
 
thanks - wasn't quite sure where to search. thanks!
 
I would propose a looping structure something like ...

i = buyer records
j = e-mail records

For i = 1 to n
For j = 1 to m
Send Email
Next j
Next i

This would start with the first buyer, go through all of some records sending emails, then iterate to the second buyer, go through ..... if I have it right.

There is something similar in the post ...

http://www.access-programmers.co.uk/forums/showthread.php?t=160598&highlight=e-mail

Which will demonstrate the looping and e-mail action. You should be able to take this to create a nested loop in the structure I have proposed.

Hope that helps,

-dK
 
Don't hesitate to invest in the time to learn the basics as it's probably the most powerful feature in Access. IMHO :)

Seconded and Amen! I was a late bloomer with DAO and ADO, once I discovered and learned it - became the best tool in my tool box.

Will post this since it is a good primer for the user, by showing how to do the same thing in each (and SQL) ....

http://www.functionx.com/vbaccess/


-dK
 

Users who are viewing this thread

Back
Top Bottom