G
Guest
I am having problems with the following piece of code. It has been written to run a report from details contained on a dialogue form and then issue the report by email as an RTF attachment. This has been working fine for some time, but, when I now run it, it creates an Excel file instead containing nothing but code
Does anyone know how this problem might have been caused and what I can do to correct it
Dim ReportName, WhereCondition As String,
StandardCondition As String, SubSectCondition As String,
DateCondition As String, BodyMessage As String,
CaptionMessage As String, StandardCaption As String,
AreaCaption As String, DateCaption As String,
Dt As New DateInf
Public Sub Form_Load(
ResetFor
End Su
Public Sub ResetForm(
'Normalise form settings and populate with dates of previous wee
Me.TabCtl7.Visible = Fals
Me.InsideHeight = 240
Me.tglAddCriteria.Caption = "Set additional criteria >>>
Me.cbxAllDates = Fals
Me.StartDate = Dt.FirstOfWeek -
Me.EndDate = Dt.LastOfWeek -
Me.StartDate.Visible = Tru
Me.EndDate.Visible = Tru
ReportName = "rptDiscontinuedCatalogue
StandardCondition = "SC<99 AND St='D'
DateCondition = " AND DiscDate Between #"
& Format$(Me.StartDate, "mm/dd/yyyy") & "# AND #"
& Format$(Me.EndDate, "mm/dd/yyyy") & "#
StandardCaption = "Preparing discontinued report for
AreaCaption = "all areas,
DateCaption = "dates as specified
BodyMessage = "Karen," & Chr(10) & Chr(10)
& "Please find attached the latest discontinued product update.
End Su
Private Sub cmdWeeklyReport_Click(
'Mail discontinued report using weekly criteri
Dim Msg, Style, Title, Respons
Msg = "Are you sure you want to mail the weekly report?
Style = vbYesNo + vbExclamation + vbApplicationModa
Title = "Mail Weekly Discontinued Report
Response = MsgBox(Msg, Style, Title
If Response = vbNo The
Exit Su
End I
ResetFor
If Val(Me.cbxAllDates) = -1 The
WhereCondition = "Department<>'94'" &
"AND SC<99 AND St='D'
Els
WhereCondition = "Department<>'94'"
& "AND SC<99 AND St='D' AND DiscDate Between #"
& Format$(Me.StartDate, "mm/dd/yyyy") & "# AND #"
& Format$(Me.EndDate, "mm/dd/yyyy") & "#
End I
Me.Caption = "Preparing report (electrical excluded)...
DoCmd.OpenReport
ReportName:=ReportName,
View:=acViewPreview,
WhereCondition:=WhereConditio
Me.Caption = "Discontinued Report
DoCmd.SendObject acSendReport, , acFormatRTF,
"Karen Roberts",
"Debbie Thompson", , "Discontinued Product Update for Week ",
BodyMessage, Tru
End Sub
Does anyone know how this problem might have been caused and what I can do to correct it
Dim ReportName, WhereCondition As String,
StandardCondition As String, SubSectCondition As String,
DateCondition As String, BodyMessage As String,
CaptionMessage As String, StandardCaption As String,
AreaCaption As String, DateCaption As String,
Dt As New DateInf
Public Sub Form_Load(
ResetFor
End Su
Public Sub ResetForm(
'Normalise form settings and populate with dates of previous wee
Me.TabCtl7.Visible = Fals
Me.InsideHeight = 240
Me.tglAddCriteria.Caption = "Set additional criteria >>>
Me.cbxAllDates = Fals
Me.StartDate = Dt.FirstOfWeek -
Me.EndDate = Dt.LastOfWeek -
Me.StartDate.Visible = Tru
Me.EndDate.Visible = Tru
ReportName = "rptDiscontinuedCatalogue
StandardCondition = "SC<99 AND St='D'
DateCondition = " AND DiscDate Between #"
& Format$(Me.StartDate, "mm/dd/yyyy") & "# AND #"
& Format$(Me.EndDate, "mm/dd/yyyy") & "#
StandardCaption = "Preparing discontinued report for
AreaCaption = "all areas,
DateCaption = "dates as specified
BodyMessage = "Karen," & Chr(10) & Chr(10)
& "Please find attached the latest discontinued product update.
End Su
Private Sub cmdWeeklyReport_Click(
'Mail discontinued report using weekly criteri
Dim Msg, Style, Title, Respons
Msg = "Are you sure you want to mail the weekly report?
Style = vbYesNo + vbExclamation + vbApplicationModa
Title = "Mail Weekly Discontinued Report
Response = MsgBox(Msg, Style, Title
If Response = vbNo The
Exit Su
End I
ResetFor
If Val(Me.cbxAllDates) = -1 The
WhereCondition = "Department<>'94'" &
"AND SC<99 AND St='D'
Els
WhereCondition = "Department<>'94'"
& "AND SC<99 AND St='D' AND DiscDate Between #"
& Format$(Me.StartDate, "mm/dd/yyyy") & "# AND #"
& Format$(Me.EndDate, "mm/dd/yyyy") & "#
End I
Me.Caption = "Preparing report (electrical excluded)...
DoCmd.OpenReport
ReportName:=ReportName,
View:=acViewPreview,
WhereCondition:=WhereConditio
Me.Caption = "Discontinued Report
DoCmd.SendObject acSendReport, , acFormatRTF,
"Karen Roberts",
"Debbie Thompson", , "Discontinued Product Update for Week ",
BodyMessage, Tru
End Sub