If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Email Report
I have been trying to setup my reports so that the user can email them, I
have maged to do this but have came accross a problem when I have a where clause see code below.... Private Sub Command8_Click() Dim ReportName As String Dim strWhere As String ReportName = "SalesReport1" strWhere = "InvoiceDate Between #" & _ Format(Me.Startdate, "mm/dd/yyyy") & "#" & _ " and #" & Format(Me.EndDate, "mm/dd/yyyy") & "#" DoCmd.SendObject acReport, ReportName, strWhere End Sub The stWhere keeps appearing in the To feild of the email! Any suggestions would be gratefuly recieved. Thanks S |
#2
|
|||
|
|||
Email Report
SG wrote:
I have been trying to setup my reports so that the user can email them, I have maged to do this but have came accross a problem when I have a where clause see code below.... Private Sub Command8_Click() Dim ReportName As String Dim strWhere As String ReportName = "SalesReport1" strWhere = "InvoiceDate Between #" & _ Format(Me.Startdate, "mm/dd/yyyy") & "#" & _ " and #" & Format(Me.EndDate, "mm/dd/yyyy") & "#" DoCmd.SendObject acReport, ReportName, strWhere End Sub The stWhere keeps appearing in the To feild of the email! Any suggestions would be gratefuly recieved. Thanks S You have missed out some parameters. The format for SendObject is this. DoCmd.SendObject acSendReport, ReportName, acFormatRTF, SendTo, , , Subject, message If you use the intellisense, it will show you what is required. -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/200612/1 |
#3
|
|||
|
|||
Email Report
I understand that bu where should I have the 'strWhere' statement?
"dneagle via AccessMonster.com" u8504@uwe wrote in message news:6a4e5f3450e66@uwe... SG wrote: I have been trying to setup my reports so that the user can email them, I have maged to do this but have came accross a problem when I have a where clause see code below.... Private Sub Command8_Click() Dim ReportName As String Dim strWhere As String ReportName = "SalesReport1" strWhere = "InvoiceDate Between #" & _ Format(Me.Startdate, "mm/dd/yyyy") & "#" & _ " and #" & Format(Me.EndDate, "mm/dd/yyyy") & "#" DoCmd.SendObject acReport, ReportName, strWhere End Sub The stWhere keeps appearing in the To feild of the email! Any suggestions would be gratefuly recieved. Thanks S You have missed out some parameters. The format for SendObject is this. DoCmd.SendObject acSendReport, ReportName, acFormatRTF, SendTo, , , Subject, message If you use the intellisense, it will show you what is required. -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/For...forms/200612/1 |
#4
|
|||
|
|||
Email Report
Look at the syntax of the SendObject Method
expression.SendObject(ObjectType, ObjectName, OutputFormat, To, Cc, Bcc, Subject, MessageText, EditMessage, TemplateFile) This means. DoCmd.SendObject acSendReport, ReportName, ReportFormat, etc. You have your strWhere in the place where you need the report's format, such as acFormatHTML. I don't think you can include your Where clause anywhere in the SendObject method, but I would try including the where clause in the report itself by adding criteria in its RecordSource referring to your parameters - replace the implicit "Me" (which works in the context of the form but not the report) with an explicit reference to the form. The criteria for InvoiceDate should look something like this: Between [Forms]![YourForm]![Startdate] and [Forms]![YourForm]![EndDate] "SG" wrote: I have been trying to setup my reports so that the user can email them, I have maged to do this but have came accross a problem when I have a where clause see code below.... Private Sub Command8_Click() Dim ReportName As String Dim strWhere As String ReportName = "SalesReport1" strWhere = "InvoiceDate Between #" & _ Format(Me.Startdate, "mm/dd/yyyy") & "#" & _ " and #" & Format(Me.EndDate, "mm/dd/yyyy") & "#" DoCmd.SendObject acReport, ReportName, strWhere End Sub The stWhere keeps appearing in the To feild of the email! Any suggestions would be gratefuly recieved. Thanks S |
#5
|
|||
|
|||
Email Report
SG wrote:
I understand that bu where should I have the 'strWhere' statement? I have been trying to setup my reports so that the user can email them, I have maged to do this but have came accross a problem when I have a where [quoted text clipped - 27 lines] Subject, message If you use the intellisense, it will show you what is required. It goes at the end. You still need a sent to parameter. You would be better off taking the strWhere parameter from a query. DoCmd.SendObject acSendReport, Report\Name, acFormatRTF, strTo, , strBCC, strSubject, strWhere -- Message posted via http://www.accessmonster.com |
Thread Tools | |
Display Modes | |
|
|