send email with results of query

iankerry

Registered User.
Local time
Today, 23:22
Joined
Aug 10, 2005
Messages
190
hi

i can get access to send an email, even with some data from the form in the email(thanks to this forum).

However what i would like to do is this:

i am on a form with date records of film events i organise for a variety of venues.

i want to click a button and email a particular venue with a list of film events they have booked in the future.

i assume i will need to run a query to do this, which won't be a problem, but how do i put the resulting data into an email, (not an attachment)?

Any pointers greatly appreciated.

thanks

ian
 
Hi,

Open you query in a recordset and loop thhrough it to create a text string of your values that will become the body of your email message.

Let me know if you need more details.

Simon B.
 
Hi,

Open you query in a recordset and loop thhrough it to create a text string of your values that will become the body of your email message.

Let me know if you need more details.

Simon B.

hi simon, thanks for responding. A few more details would be appreciated.

I know how to do a query, but a query in a recordset i dont think i have done and as for looping through it - sounds fun, but not sure where to start. a couple of pointers would be grand.

cheers

ian
 
Hi Ian,

In a module on in a button click event code:

Dim rst as DAO.Recordset ' I use DAO you can use ADO if you want I'm not gonne debate it now.

Set rst = CurrentDB.OpenRecordset(your_query_in_SQL)

While Not rst.EOF
strBody = strBody & rst!Field_Name & vbNewLine ' Append to your message values from the query

rst.MoveNext ' Get to the next record

Wend

DoCmd.SendObject acSendNoObject, .... strBody... ' Check the syntax for this


You will need to check the syntax and create you own string for the body of the email, but that should give you an idea.

Simon B.
 
Thanks Simon, will give that a go. Appreciate your time.

Ian
 

Users who are viewing this thread

Back
Top Bottom