PC Review


Reply
Thread Tools Rate Thread

Auto Email Feature

 
 
JK
Guest
Posts: n/a
 
      14th Aug 2008
I've been using the following code (see bottom) attached to a command button
that automatically creates a report in snapshot format and then inserts it
into an email as an attachment. The email addresses are also auto-added based
on a prior list box selection.

It works great. I would just like to now use it in conjunction with a report
that requires the user to make a selection before the report can run. In my
example, I want to generate a report that displays every customer assigned to
a specific salesperson that has not purchased anything in 90 days and has
equipment on loan.

So normall when I run the report I have a window appear with a combo box and
the user selects the salesperson.

I just don't know how incorporate the salesperson selection process in the
auto-email feature.

I want to select a salesperson in the listbox and have the report for that
salesperson created and inserted into an email in snapshot format.

Any help would be great! Thx!

Also, I'm told Access is going by the wayside - is that true?


Private Sub cmdMailRep_ort_Click()

Dim MailList As String
Dim strCCTo As String
Dim strBccTo As String
Dim strMsg As String
Dim Address As Variant
'Report variables
Dim strFilter As String
Dim rpt As String

'Create string for list of mail recipients
'lstMailer is a multiselect listbox
For Each Address In Me.lstMailer.ItemsSelected
MailList = MailList & ";" & """" & Me.lstMailer.ItemData(Address) & """"
Next Address
If MailList = "" Then
MailList = ""
Else
MailList = right(MailList, Len(MailList) - 1)
End If
'**********************
'set report to print
rpt = "Open Workorders" 'report name goes here. This is the name of the
report you wish to send.
strFilter = "" 'add code to create filter for report if necessary

strCCTo = "(E-Mail Removed); " 'Additional email addreses go here
strBccTo = "" 'Additional blind email addrresses go here
strMsg = "Attached to this email, you'll find a report containing all open
workorders." 'Default message content goes here

DoCmd.OpenReport rpt, acPreview, , strFilter
'The next line sends the report in RTF format.
'This can be changed to several formats, search the help file for acFormatRTF

DoCmd.SendObject acSendReport, rpt, acFormatSNP, MailList, strCCTo,
strBccTo, "Open Workorders", strMsg, -1
DoCmd.Close
MsgBox "The Unfinished Workorders Report has been sent!", , "Send E-Mail"
Exit_cmdPrint_Click:
Exit Sub

Err_cmdPrint_Click:
MsgBox Err.Description
Resume Exit_cmdPrint_Click

End Sub

 
Reply With Quote
 
 
 
 
Alex Dybenko
Guest
Posts: n/a
 
      15th Aug 2008
Hi,
you can do like this. Say your report's recordsource is qryOpenWorkorders.
make a new query qryOpenWorkorders2 with such SQL:
Select * from qryOpenWorkorders
and set this query as a recordsource for the report.

now before sending or opening report add such line:
currentdb.querydefs("qryOpenWorkorders2").SQL="Select * from
qryOpenWorkorders Where SalesPerson='" & me.lstSalesPerson & "'"

lstSalesPerson - is a list box where sales person selected

--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com


"JK" <jasonk at necoffeeco dot com> wrote in message
news:35542400-DFC6-43E6-B688-(E-Mail Removed)...
> I've been using the following code (see bottom) attached to a command
> button
> that automatically creates a report in snapshot format and then inserts it
> into an email as an attachment. The email addresses are also auto-added
> based
> on a prior list box selection.
>
> It works great. I would just like to now use it in conjunction with a
> report
> that requires the user to make a selection before the report can run. In
> my
> example, I want to generate a report that displays every customer assigned
> to
> a specific salesperson that has not purchased anything in 90 days and has
> equipment on loan.
>
> So normall when I run the report I have a window appear with a combo box
> and
> the user selects the salesperson.
>
> I just don't know how incorporate the salesperson selection process in the
> auto-email feature.
>
> I want to select a salesperson in the listbox and have the report for that
> salesperson created and inserted into an email in snapshot format.
>
> Any help would be great! Thx!
>
> Also, I'm told Access is going by the wayside - is that true?
>
>
> Private Sub cmdMailRep_ort_Click()
>
> Dim MailList As String
> Dim strCCTo As String
> Dim strBccTo As String
> Dim strMsg As String
> Dim Address As Variant
> 'Report variables
> Dim strFilter As String
> Dim rpt As String
>
> 'Create string for list of mail recipients
> 'lstMailer is a multiselect listbox
> For Each Address In Me.lstMailer.ItemsSelected
> MailList = MailList & ";" & """" & Me.lstMailer.ItemData(Address) &
> """"
> Next Address
> If MailList = "" Then
> MailList = ""
> Else
> MailList = right(MailList, Len(MailList) - 1)
> End If
> '**********************
> 'set report to print
> rpt = "Open Workorders" 'report name goes here. This is the name of the
> report you wish to send.
> strFilter = "" 'add code to create filter for report if necessary
>
> strCCTo = "(E-Mail Removed); " 'Additional email addreses go here
> strBccTo = "" 'Additional blind email addrresses go here
> strMsg = "Attached to this email, you'll find a report containing all open
> workorders." 'Default message content goes here
>
> DoCmd.OpenReport rpt, acPreview, , strFilter
> 'The next line sends the report in RTF format.
> 'This can be changed to several formats, search the help file for
> acFormatRTF
>
> DoCmd.SendObject acSendReport, rpt, acFormatSNP, MailList, strCCTo,
> strBccTo, "Open Workorders", strMsg, -1
> DoCmd.Close
> MsgBox "The Unfinished Workorders Report has been sent!", , "Send E-Mail"
> Exit_cmdPrint_Click:
> Exit Sub
>
> Err_cmdPrint_Click:
> MsgBox Err.Description
> Resume Exit_cmdPrint_Click
>
> End Sub
>


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
auto save feature (not auto recovery) Dawnee Microsoft Excel Misc 3 20th Jan 2009 09:47 PM
auto sum feature Tammy Microsoft Excel Worksheet Functions 2 12th Sep 2008 01:06 AM
Using auto sum feature =?Utf-8?B?RGF2ZQ==?= Microsoft Excel Misc 3 25th Sep 2007 04:57 PM
Email. Remove names from the auto-complete feature. =?Utf-8?B?TW8gTHVuZA==?= Microsoft Outlook Discussion 2 25th Feb 2006 08:28 PM
auto remember or auto suggest feature-how to disable =?Utf-8?B?bmV3IHhwIHVzZXI=?= Windows XP General 2 19th Mar 2004 03:06 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:57 PM.