Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using a Query to make Selections

0 views
Skip to first unread message

AT

unread,
Oct 28, 2002, 12:08:48 PM10/28/02
to
I am doing a vounteer project for a good cause. The owner wants to be
able to select one or more people from the client database and have it
boot up Outlook with the names populated in the "To:" block (They
don't want to cut and paste). I have placed an Email check box into a
Query that lists all clients with their email addresses
(qryAllEmailAddresses). Its a small number (<100). I have also created
a new query called (qrySelectedEmailAddresses). The idea is that a
query comes up on screen that lists all clients w/email addresses, you
check the ones you want, and then have them populate Outlook. The
program works if I fill out the Query before the program is run. I
can't figure out how to pause the program when making the initial
selections, and then continue on with the new query. I have documented
the spot where I could use some help. Can anyone please help me?
Thanks. Code as follows:

Private Sub cmdSendEmail_Click()

Form_frmInput_Contact_Info.Visible = False

Dim dbD As DAO.Database
Dim rsR As DAO.Recordset
Dim strAddresses As String

Set dbD = CurrentDb()
DoCmd.OpenQuery "qryAllEmailAddresses"
MsgBox "Please select your email recipients" & vbCrLf & _
"by checking the appropriate boxes.", , "Let's Email Someone!"
If vbOK = 1 Then

'hold program to make selections.
'then continue on.

Set rsR = dbD.QueryDefs("qrySelectedEmailAddresses").OpenRecordset(dbOpenSnapshot)

Do Until rsR.EOF
With rsR.Fields("E-Mail Address")
If Not IsNull(.Value) Then
strAddresses = strAddresses & "; " & .Value
rsR.MoveNext
End If
End With
Loop

rsR.Close
Set rsR = Nothing
Set dbD = Nothing

strAddresses = Mid(strAddresses, 3)

If Len(strAddresses) > 0 Then

On Error GoTo ErrorTrap

DoCmd.SendObject _
ObjectType:=acSendNoObject, ObjectName:="", OutputFormat:= _
acFormatTXT, To:=strAddresses, Cc:="", Bcc:="", Subject:= _
"", MessageText:="", EditMessage:=True, TemplateFile:=""

MsgBox "Message successfully sent."
If vbOK = 1 Then
Form_frmInput_Contact_Info.Visible = True
End
End If
End If

Exit Sub

ErrorTrap:
MsgBox "There are no cotacts for the selected query"
If vbOK = 1 Then
Form_frmInput_Contact_Info.Visible = True
End
End If

End If

End Sub

S.Clark[MVP]

unread,
Oct 29, 2002, 9:56:43 AM10/29/02
to
Rather than doing the openquery, open a form with a button. The button will
signify that they are finished making selections, and are ready to generate
the email. Add the rest of the code to the button.


--
HTH,

Steve Clark, Access MVP
Project Manager
Professional Solutions Group
www.FMSInc.com/Consulting
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

"AT" <ato...@cox.net> wrote in message
news:41fc24e8.02102...@posting.google.com...

0 new messages