Link to home
Start Free TrialLog in
Avatar of gogetsome
gogetsomeFlag for United States of America

asked on

Pass paramenter to report using DoCmd.SendObject

Hello, I'm using the following code to attach a report to an email. On the button click I get a popup to provide a recordId, once the recordId is given the email opens up and the report is attached.

I would like to be able to pass the recordId in the DoCmd.SendObject. Is that possible?

Dim stDocName As String
stDocName = "DMR_Single View"
   
DoCmd.SendObject acReport, stDocName, , ""

Open in new window

Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Short Answer: No, you cant
ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gogetsome

ASKER

Bummer, that's why I asked. I searched before posting, but wanted to verify my suspicions after reading about the method on MSDN.  Perhaps it can be accomplished without using DoCmd.SendObject?
No points please, I agree with Jeff.

You can do several things.

1.  store the parameter in a control on a form, and reference that control in the report or
2.  store the parameter as a variable and use that variable (you cannot directly reference a variable in a query, so you have to call a function that will return the variable).  Another option for this method is to use TempVars.

3.  Another method I use is when I want to send out a report to a bunch of organizations or people, but I only want them to receive their portion of the report, I will build a query that contains the ID, email, ... for each person or organization.

I then open my report without parameters (every organization).  By opening the report outside the loop, it only has to open once, not be created for each ID.

I then create a loop to loop through the recordset and set the reports Filter property to the appropriate ID, and set the FilterOn property to true.

Then, within that loop, when you reference the report, it will actually send the filtered report.
Oaky, thanks guys! I believe I get what you are saying and can probably work up a solution. I appreciate your time.
yep, agree with fyed.

If this Parameter is actuality filtering for a customer (for example)
There are ways to do this with loops and queries

Not knowing the details of your specific application, I just sketched the broad strokes...