Cannot Pull Data from the Report

Novice1

Registered User.
Local time
Today, 05:41
Joined
Mar 9, 2004
Messages
385
I posted the following code on a button (report to a first sergeant). I can't pull e-mail addresses from the report (rptLateByUnit). What am I doing wrong? Thanks

=========

DoCmd.SendObject acSendReport, "rptLateByUnit", acFormatPDF, Me.CCF_EMail, Me.CCS_Email, , "FOUO: Open Personnel Data Discrepancies", "This document contains information which must be protected in accordance with AFI 33-332, Air Force Privacy Act Program, and DoD Regulation 5400.7R, DoD Freedom of Information Act Program; and Privacy Act of 1974 as amended applies. This document is For Official Use Only." & vbCr & vbCr & _
"Whenever we become aware of a personnel data discrepancy (e.g., divorce not reported in DEERS, inaccurate SGLI, ID card discrepancy, etc), then we notify the member of the issue and ask him or her to fix the problem within 2 weeks." & vbCr & vbCr & _
"At the beginning of each month, we provide first sergeants a list of open discrepancies. We respectfully request the assistance of first sergeants in resolving any discrepancy that has been open for more than 2 weeks." & vbCr & vbCr & _
"If one or more people on the attached list are unavailable (e.g., TDY, leave, etc.), then please let us know so we can adjust the follow-up date in our tracking system." & vbCr & vbCr & _
"vr" & vbCr & vbCr & vbCr & _
"Mr. James Petersen, Cntr" & vbCr & _
"Site Manager, Moody AFB" & vbCr & _
"Comm (229) 257-3415, DSN Prefix 460" & vbCr & _
"Fax (229) 257-2904", True
 
This code is in that report? The Me reference should pull the addresses if those are the correct control names (and it would only work in Report view). Are you getting an error, or?
 
The fields are in the report (based on a query).

When I run the code I get "Compile Error: Method or data member not found."
 
If the report is open the data is available. Try cutting down the code to the minimum just to send a simple email with one address. Make sure the control you're referencing is on the report.
 
Ok ... I added the following code but I'm getting the same error.

==============

Dim myDB As Database
Dim myRS As Recordset

Set myDB = OpenDatabase("DiscrepancyAndInfoTracker.accdb")

Set myRS = myDB.OpenRecordset("qryLatebyUnit", dbOpenDynaset)


DoCmd.SendObject acSendReport, "rptLateByUnit", acFormatPDF, Me.CC_Email, Me.CCF_EMail, Me.CCS_Email, , "FOUO: Open Personnel Data Discrepancies", "This document contains information which must be protected in accordance with AFI 33-332, Air Force Privacy Act Program, and DoD Regulation 5400.7R, DoD Freedom of Information Act Program; and Privacy Act of 1974 as amended applies. This document is For Official Use Only." & vbCr & vbCr & _
"Whenever we become aware of a personnel data discrepancy (e.g., divorce not reported in DEERS, inaccurate SGLI, ID card discrepancy, etc), then we notify the member of the issue and ask him or her to fix the problem within 2 weeks." & vbCr & vbCr & _
"At the beginning of each month, we provide first sergeants a list of open discrepancies. We respectfully request the assistance of first sergeants in resolving any discrepancy that has been open for more than 2 weeks." & vbCr & vbCr & _
"If one or more people on the attached list are unavailable (e.g., TDY, leave, etc.), then please let us know so we can adjust the follow-up date in our tracking system." & vbCr & vbCr & _
"vr" & vbCr & vbCr & vbCr & _
"Mr. James Petersen, Cntr" & vbCr & _
"Site Manager, Moody AFB" & vbCr & _
"Comm (229) 257-3415, DSN Prefix 460" & vbCr & _
"Fax (229) 257-2904", True
 
You're still referring to the report in the SendObject code (which I believe should work).
 
Exactly which report record do you expect to reference? I hope it is the first. If this report needs to go to each unit commander, you can't get their email's by referencing the report.

It's not my report, I was simply saying that you can get the values from a report with Me.ControlName. If the code was initiated from the detail section, you would get that record's values. I've only used Report view a couple of times, when I wanted the sorting/grouping ability of a report with the interactivity of a form, but you can reference any record you want, just as you can on a form.
 

Users who are viewing this thread

Back
Top Bottom