Hi All,
I have a button on a form which emails a report based on the current record. This works, but occasionally (for a reason I cant yet pin-point) the next time you go to email a record the report is empty.
When I look at the underlying query I find that it has been modified. For example:
Now the 'Daily Report' is based on a very simple query:
But sometimes the filter EventNo= is getting left on the end, so it ends up as :
Can anyone see what it is in my code that is modifying the underlying query?
Cheers
-Al
I have a button on a form which emails a report based on the current record. This works, but occasionally (for a reason I cant yet pin-point) the next time you go to email a record the report is empty.
When I look at the underlying query I find that it has been modified. For example:
Code:
' *****************************************************
' **** GENERIC EMAIL BUTTON CLICK EVENT ***************
' *****************************************************
Private Sub CmdEmail_Click()
On Error GoTo CmdEmail_Click_Err
Me.Refresh
DoCmd.OpenReport "Daily Report", acViewPreview, , "EventNo='" & Me.EventNo & "'", acHidden
Me.Form.SetFocus
DoCmd.SendObject acSendReport, "Daily Report Event", acFormatPDF, "", "", "", _
"Report " & Me.EventNo
DoCmd.Close acReport, "Daily Report", acSaveNo
' *** ACTIONS LOG UPDATE ***
Actions.Value = Actions.Value & vbNewLine & "Generic Report Email Sent by " & strUser & " on " & Now()
CmdSAMEmail_Click_Err:
Select Case Err.Number
Case 2501
MsgBox ("Email has been cancelled")
DoCmd.Close acReport, "Daily Report", acSaveNo
Case 0
Case 1
Case Else
MsgBox ("Error: " & Err.Number & " " & Err.Description)
DoCmd.Close acReport, "Daily Report", acSaveNo
Me.Form.SetFocus
End Select
End Sub
Now the 'Daily Report' is based on a very simple query:
Code:
SELECT * FROM SAM;
But sometimes the filter EventNo= is getting left on the end, so it ends up as :
Code:
SELECT * FROM SAM WHERE EventNo = '123456789'
Can anyone see what it is in my code that is modifying the underlying query?
Cheers
-Al