Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report data problem in snapshot view

Status
Not open for further replies.

sanders720

Programmer
Aug 2, 2001
421
US
I have a report that is being called via e-mail. When I was testing, I used Preview to assure that the form looked correct. In the process, I used the Activate event to populate three areas of the report, as indicated in the code below. The problem is, this judt doesn't take in the snapshot format with the e-mail.

Private Sub Report_Activate()
LoginName

Me.txtRelBy.Value = EmployeeINIT
Me.txtRelDate.Value = Date

Me.txtNeedBy.Value = Forms!frmPurchasedPartsListPRE.txtNeedBy.Value

' Close Out Form
Forms!frmPurchasedPartsListPRE.Close

End Sub


The line of code for the email looks as follows...

' Send E-Mail
DoCmd.SendObject acSendReport, "rptPurchased Parts List EE", "Snapshot Format", "abc@def.com", "xyz@def.com", , "Metro Requisition: " & RN + 1 & " Ready for Processing. Preferred Delivery by " & txtNeedBy & ".", "The attached file represents the data that is in the Purchased Requisition Database. Please save the file for reference. Feel free to contact me if you have any questions about it."


Thanks in advance for any help you can provide
 
When you reference a field on your form use the following method: Forms![FormName]![FormFieldName]. Sometimes using just the form name (for example - RN and txtNeedBy) doesn't work.

Also, when entering multiple e-mail recipient addresses do not use the comma in the Docmd statement. Most e-mail programs recognize the semicolon (;) as a separator so I've used that in my example below. Please omit or change if your e-mail program does not recognize it.

Take the below code and give it a try after changing the field references.


Dim stDocName As String
Dim strOutputFormat As String
Dim strRecipName As String
Dim strSubject As String
Dim strMesg As String

stDocName = "rptPurchased Parts List EE"
strOutputFormat = "Snapshot Format"
strRecipName = "abc@def.com;xyz@def.com"
strSubject = "Metro Requisition: " & RN + 1 & " Ready for Processing. Preferred Delivery by " & txtNeedBy & ".",
strMesg = "The attached file represents the data that is in the Purchased Requisition Database. Please save the file for reference. Feel free to contact me if you have any questions about it."
'Write the record before sending it.
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
'Send E-Mail
DoCmd.SendObject acSendReport, stDocName, strOutputFormat, strRecipName, , , strSubject, strMesg
DoCmd.Quit

--
Mike

Why make it simple and efficient when it can be complex and wonderful?
 
Oops...Please omit the DoCmd.Quit command at the end of my code. I accidentally included it, as I was copying code from an existing database when sending the reply.

--
Mike

Why make it simple and efficient when it can be complex and wonderful?
 
This portion of your code produces an argument not optional error.

DoCmd.DoMenuItem , acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
 
Okay, try this instead:

DoCmd.RunCommand acCmdSaveRecord


--
Mike

Why make it simple and efficient when it can be complex and wonderful?
 
This makes it work again, but the symptoms are indentical to what I had in my first post. The data is just not making it to the form. If I do a preview, it is there - however it doesn't make it to the file attachemnt (snapshot view) in e-mail.

I think there must be a problem with the form activate event. Perhaps this is the wrong place to put the code. If so, what would be the right place. Or, is there yet a different solution.

Thanks for your help...

 
When you print preview are you previewing your report or your form? Your form will always look correct in print preview so we can't determine anything by previewing the completed form.

I don't think that you need the report's activate event. All fields on the report should be found on the record. Try creating the values for txtRelBy, txtRelDate, and txtNeedBy on your form. Can the user input these values into the form? Why do you wish to define them on the report and not the form?

Thanks.

--
Mike

Why make it simple and efficient when it can be complex and wonderful?
 
Thanks for your reply. I will try to add a little more clarity here.

The release date is the current system date. No need to store this data anywhere

The Date needed by is entered on a calendar control on a form prior to moving to the report.

The Released bt field is the current users login initials. This is retrieved from another database. EmployeeINIT is the variable used, and is a public variable.

The code looks like this...

' Partial Code from form
' **********************************************************
' Send Verification E-Mail
Dim JobNo As Long
Dim P As String ' Define Path

JobNo = Forms!frmReportsListing.Combo8.Value

' Send E-Mail

Dim strDocName As String
Dim strOutputFormat As String
Dim strReceipName As String
Dim strCopyName As String
Dim strSubject As String
Dim strMesg As String

strDocName = "rptPurchased Parts List EE"
strOutputFormat = "Snapshot Format"
strReceipName = "plindquist@metromachine.com"
strCopyName = "sanders@metromachine.com; rschmaltz@metromachine.com"
strSubject = "Metro Requisition: " & RN + 1 & " Ready for Processing. Preferred Delivery by " & txtNeedBy & "."
strMesg = "The attached file represents the data that is in the Purchased Requisition Database. Please save the file for reference. Feel free to contact me if you have any questions about it."

' DoCmd.DoMenuItem , acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.RunCommand acCmdSaveRecord

DoCmd.SendObject acSendReport, strDocName, strOutputFormat, strReceipName, strCopyName, , strSubject, strMesg

Debug.Print "Send Verification E-Mail"; E

' Preview
' DoCmd.OpenReport "rptPurchased Parts List EE", acViewPreview

P = "\\deepblue\EngineeringBOM\ReleaseRecord\" & Str(JobNo) & "\test"
Debug.Print P

' Save copy in Folder
' DoCmd.OutputTo acOutputReport, "rptPurchased Parts List EE", "Snapshot Format", P

GoTo proceed1

Skip1:

MsgBox "No Records to Process at this time..."

proceed1:



' Complete code on form activate (prompted by button on prior form...
' **********************************************************
Private Sub Report_Activate()
LoginName

Me.txtRelBy.Value = EmployeeINIT
Me.txtRelDate.Value = Date

Me.txtNeedBy.Value = Forms!frmPurchasedPartsListPRE.txtNeedBy.Value

' Close Out Form
Forms!frmPurchasedPartsListPRE.Close

End Sub

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top