View Full Version : send email with results of query


iankerry
03-16-2009, 02:28 PM
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

SimonB1978
03-16-2009, 03:57 PM
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.

iankerry
03-17-2009, 01:54 AM
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

SimonB1978
03-17-2009, 03:03 AM
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.

iankerry
03-17-2009, 04:03 AM
Thanks Simon, will give that a go. Appreciate your time.

Ian