X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
   Reply to this topicStart new topic
> How To Use A Form Contact Source And Send An Email To Each, Access 2016    
post Jul 12 2018, 12:39 AM

Posts: 1
Joined: 12-July 18

Hey guys,

First of all thank you for reading my post and for your attempt at helping.
I'm stuck on a project that involves the following:

I have a one main form which contains core information about a contact.
The data elements in the main form are :
a) Name
b) Phone Number
c) Email Address
d) Address

There are 4 sub-forms attached to the main form.
Each of the sub-forms have a different data source.

Within the main form, I have two buttons:
The first button exports EACH sub-form into an excel file and saves them individually into a folder in "C:\" drive when there is data on those data sources
The second button opens an email in Outlook with the number of attachments saved on the "C:\" drive above

Here is where I need your help!

The export and the "send" button are working great.
However, I don't want to sit there and click on that export + send button 5K times.

How do I use my "form" to loop through the records, execute the codes above and send an email to EACH of my contacts without my manual clicking?

THANK YOU for taking the time to read my post ... BTW this is my first post in UtterAccess!

Go to the top of the page
post Jul 12 2018, 02:27 AM

Posts: 3,562
Joined: 19-October 10

Yes, there are two kinds of loop (as far as I know) available to you in VBA a DO LOOP and a FOR NEXT

I think the Do loop sounds good in this case.
Its hard to write some code to demonstrate it too much as it depends abit on your existing code. If, for example its using the controls on the form to populate the reports then you'll need to iterate through all the records on the form. That wouldn't be my personal preference as instead I'd open a recordset in VBA and loop through that (less on screen mess).

Either way, thats a start for you. Tell us what more information you need and we'll continue to try and fill in the gaps.
Go to the top of the page
post Jul 12 2018, 05:06 AM

UtterAccess VIP
Posts: 9,820
Joined: 10-February 04
From: South Charleston, WV


One point you need to clarify: is there anything different about each email or are they all exactly the same?

I would use an unbound form with a button to launch the emails with recordset code based on the table to loop through the table and execute either Outlook object code or Docmd.SendObject.

I've never done 5,000 at a shot myself.

Robert Crouser

My company's website
Go to the top of the page

Custom Search
RSSSearch   Top   Lo-Fi    18th July 2018 - 07:30 AM