Solved

Pass paramenter to report using DoCmd.SendObject

Posted on 2013-10-23
6
501 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 500 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 48

Expert Comment

by:Dale Fye (Access MVP)
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

705 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