Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Pass paramenter to report using DoCmd.SendObject

Posted on 2013-10-23
6
Medium Priority
?
535 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
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.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

636 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