?
Solved

Pass paramenter to report using DoCmd.SendObject

Posted on 2013-10-23
6
Medium Priority
?
520 Views
Last Modified: 2013-10-23
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

0
Comment
Question by:gogetsome
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 39594723
Short Answer: No, you cant
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 2000 total points
ID: 39594753
Ultimately you need a system to "select" this parameter and not rely on parameter prompts.

Then this value is stored and you can call it whenever you like


There are many ways to do this, but one is to use a Public variable
Create the variable in a module
    Public lngpubYourVariable as Long

Then create a public function to retrieve it:
Public Function GetYourVariable() as long
    GetYourVariable
End function

Now you can create a system to select it (or type it in, ...etc)

...then you can retrieve this vale with the function

msgbox GetYourVariable()

How this all would fit in with your specific app, is another concern, so, to be sure, lets see if another Expert has something more elegant....

JeffCoachman
0
 

Author Comment

by:gogetsome
ID: 39594756
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?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 48

Expert Comment

by:Dale Fye
ID: 39594821
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.
0
 

Author Closing Comment

by:gogetsome
ID: 39594831
Oaky, thanks guys! I believe I get what you are saying and can probably work up a solution. I appreciate your time.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 39595046
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...
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question