Help: How to connect currntDb to open query?

F

Frank Johnson

I am writing a small emailer for a retail application in access.
Anyways, using the OpenRecordSet I can send emails to an entire table or
query.

Example

'strSQL = "SELECT * FROM [main data]"
'Set rec = CurrentDb().OpenRecordset(strSQL)
'rec.MoveFirst
' DoCmd.SetWarnings False
'Do While rec.EOF = False
' DoCmd.SendObject acSendNoObject, , acFormatText, rec!Email, ,
, "This is the subject", "This is my message to you, you filthy
animal.", False
' strEmail = strEmail & rec!Email & ";"
' rec.MoveNext
'Loop


But what I would like to do, is open a query of my choosing and filter
it using the gui interface. Now, I would like to go to my email form and
select the open query which I have already queried on and use that data
for the email. Is this possible?

I could make the query a static name, but what would be the command to
set the CurrentDB to a currently opened filtered query?

Thanks
 
P

Perry

But what I would like to do, is open a query of my choosing and filter
it using the gui interface.

It's not entirely clear what you mean here. Do you mean:
You want to filter in a form which email addressee you would like
to send a email to? Pls confirm
In other words, users have to indicate which email addressees need to be
excluded from the mass email action?

Can't you include a boolean field in the table/query that indicates whether
an email addressee needs to be sent an email? Default value: True

Design a form with [main data] as underlying recordsource and include
the extra field you just created and you have a gui in which users can
filter the recordset for your mass email action.

Assuming the name of this extra field is: SendMail
your SQL string needs to be adjusted a bit
to read something like:

SELECT * FROM [main data] WHERE SendMail = True

I think this will answer your second question as well.

Krgrds,
Perry

Frank Johnson said:
I am writing a small emailer for a retail application in access.
Anyways, using the OpenRecordSet I can send emails to an entire table or
query.

Example

'strSQL = "SELECT * FROM [main data]"
'Set rec = CurrentDb().OpenRecordset(strSQL)
'rec.MoveFirst
' DoCmd.SetWarnings False
'Do While rec.EOF = False
' DoCmd.SendObject acSendNoObject, , acFormatText, rec!Email, ,
, "This is the subject", "This is my message to you, you filthy
animal.", False
' strEmail = strEmail & rec!Email & ";"
' rec.MoveNext
'Loop


But what I would like to do, is open a query of my choosing and filter
it using the gui interface. Now, I would like to go to my email form and
select the open query which I have already queried on and use that data
for the email. Is this possible?

I could make the query a static name, but what would be the command to
set the CurrentDB to a currently opened filtered query?

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top