Coding with sql, input parameters

S

Stephanie

Hi. I'd like my code to allow users to input parameters.
I'm trying to create an email list to those users in
certain groups, but don't want to send the email to all
groups. I have code that sends emails to members (see
below). I'd like to replace the select statement with a
call to open an exisitng form which allows users to choose
the group name. The form is GroupParam. Can that be
done? If not, GroupMembers table contains GroupID and
ContactID. How could I use these to get an interactive
input? Thanks, Stephanie


Private Sub EmailMember_Click()
Dim rst As DAO.Recordset
Dim strTo As String
Set rst = CurrentDb.OpenRecordset("SELECT [EmailName]
FROM Contacts WHERE [EmailName] Is Not Null AND [Member]
=Yes")
With rst
Do Until .EOF
strTo = strTo & ![EmailName] & ";"
.MoveNext
Loop
.Close
End With
strTo = Left(strTo, Len(strTo) - 1)
Set rst = Nothing
'line that would open Outlook to a new message with the
bcc:
'box populated with the list you built in strTo
DoCmd.SendObject acSendNoObject, , , , , strTo, "Member
Email Link"

End Sub
 

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

Top