Solved

Pass paramenter to report using DoCmd.SendObject

Posted on 2013-10-23
6
451 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
  • 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 47

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now