talytech
07-16-2007, 07:48 AM
OK .. I'm going to try to exlplain what I want to do first. Here goes ... I have a report that I want to send via email in a snapshot format using the sendObject method when the user clicks the button "Send Form".
.. the criteria for the report is based on a field on my form. ([requestId] = forms!myFrm![requestId]) ... So as long as the form is open, the report opens with the correct data.
Now ... what I have done works the first time I try it, but if I make a change to the form and click the "Send Form" button, it sends the report but the report doesn't reflect the changes. Now if I click on the report to open it from the database window, it opens with the correct data.
My button on my form is calling a user defined function.
Function submitRequest()
Dim frm As Form
Dim Name, strHrRep, recip As String
Dim numdays As Long
Set frm = form_frmUpdate
Name = "Tee Lewis"
strHrRep = "Fred.Flintstone@test.com"
If frm.NewRecord = True Then
If numdays <= 90 Then
recip = "Barney.Rubble@test.com"
'DoCmd.SendObject _
acSendReport, "rptBI_screening_request_form", _
acFormatSNP, recip, , , _
"CONFIDENTIAL: Background Screening Request For: " & Name, _
"Please find attached, the request cover sheet and the " & _
"employment application for " & Name & Chr(13) & Chr(13) & _
"Submitted by Human Resources: " & strHrRep, -1
'Call Read_HR
ElseIf numdays > 90 Then
recip = "Wilma.Flintstone@test.com"
'DoCmd.SendObject _
acSendReport, "rptBI_screening_request_form", acFormatSNP, _
recip, , , "CONFIDENTIAL: Background Screening Request For: " & Name, _
"Please find attached, the request cover sheet and the " & _
"employment application for " & Name & Chr(13) & Chr(13) & _
"Submitted by Human Resources: " & strHrRep, -1
'Call Read_HR
End If
Else
recip = "Betty.Rubble@test.com"
'DoCmd.SendObject _
acSendReport, "rptBI_screening_request_form", acFormatSNP, recip, , , _
"CONFIDENTIAL: Background Screening Request For: " & Name, _
"Please find attached, the request cover sheet and the " & _
"employment application for " & Name & Chr(13) & Chr(13) & _
"Submitted by Human Resources: " & strHrRep, -1
'Call Read_HR
End If
End Function
My button on my form calls the above function. If I put that code behind my button then it works fine. I can cancel the email and make changes to the record and send again and the report reflects the changes.
But if I call that function, the report shows the right data the first time but if I choose to cancel the email and make a change to the record and send again, the report shows the same data as the first time.
Any ideas ... I hope this is clear .. its the only way I can explain it.
Edited 17-Jul-07 by geekgirlau. Reason: insert line breaks
.. the criteria for the report is based on a field on my form. ([requestId] = forms!myFrm![requestId]) ... So as long as the form is open, the report opens with the correct data.
Now ... what I have done works the first time I try it, but if I make a change to the form and click the "Send Form" button, it sends the report but the report doesn't reflect the changes. Now if I click on the report to open it from the database window, it opens with the correct data.
My button on my form is calling a user defined function.
Function submitRequest()
Dim frm As Form
Dim Name, strHrRep, recip As String
Dim numdays As Long
Set frm = form_frmUpdate
Name = "Tee Lewis"
strHrRep = "Fred.Flintstone@test.com"
If frm.NewRecord = True Then
If numdays <= 90 Then
recip = "Barney.Rubble@test.com"
'DoCmd.SendObject _
acSendReport, "rptBI_screening_request_form", _
acFormatSNP, recip, , , _
"CONFIDENTIAL: Background Screening Request For: " & Name, _
"Please find attached, the request cover sheet and the " & _
"employment application for " & Name & Chr(13) & Chr(13) & _
"Submitted by Human Resources: " & strHrRep, -1
'Call Read_HR
ElseIf numdays > 90 Then
recip = "Wilma.Flintstone@test.com"
'DoCmd.SendObject _
acSendReport, "rptBI_screening_request_form", acFormatSNP, _
recip, , , "CONFIDENTIAL: Background Screening Request For: " & Name, _
"Please find attached, the request cover sheet and the " & _
"employment application for " & Name & Chr(13) & Chr(13) & _
"Submitted by Human Resources: " & strHrRep, -1
'Call Read_HR
End If
Else
recip = "Betty.Rubble@test.com"
'DoCmd.SendObject _
acSendReport, "rptBI_screening_request_form", acFormatSNP, recip, , , _
"CONFIDENTIAL: Background Screening Request For: " & Name, _
"Please find attached, the request cover sheet and the " & _
"employment application for " & Name & Chr(13) & Chr(13) & _
"Submitted by Human Resources: " & strHrRep, -1
'Call Read_HR
End If
End Function
My button on my form calls the above function. If I put that code behind my button then it works fine. I can cancel the email and make changes to the record and send again and the report reflects the changes.
But if I call that function, the report shows the right data the first time but if I choose to cancel the email and make a change to the record and send again, the report shows the same data as the first time.
Any ideas ... I hope this is clear .. its the only way I can explain it.
Edited 17-Jul-07 by geekgirlau. Reason: insert line breaks