Hello.
Okay, so I have an Option Group with 6 reports on the Right hand side of a form. On the left, I have 4 command buttons. 1) Preview 2) Print 3) Save off 4) Email.
I want the user to be able to select a report's radio button and click one of the four command buttons. Currently, Preview and Print work. But the Reports have parameters in their queries. I'm prompted for the values for the Print and Preview buttons, but for some reason, I can not get the Email command button to work.
I also don't know where to start for saving the report to a network drive. I'm assuming I'll run into the same error.
(Error: Argument not Optional)
Here's the code I have so far. Any ideas??
THANKS A MILLION! -
Sub PrintReports(PrintMode As Integer)
-
On Error GoTo Err_Preview_Click
-
'This procedure used in Preview_Click and Print_Click Sub procedure.
-
'Preview or print report selected in the SelectReports option group.
-
'Then close the Select Reports Dialog Form.
-
-
Select Case Me!SelectReports
-
Case 1
-
DoCmd.OpenReport "R_Reasonableness", PrintMode
-
Case 2
-
DoCmd.OpenReport "R_ADJ", PrintMode
-
Case 3
-
DoCmd.OpenReport "R_Detail", PrintMode
-
Case 4
-
DoCmd.OpenReport "R_Detail2", PrintMode
-
Case 5
-
DoCmd.OpenReport "R_Summary", PrintMode
-
Case 6
-
DoCmd.OpenReport "R_Summary2", PrintMode
-
End Select
-
DoCmd.Close acForm, "F_REPORTS"
-
-
Exit_Preview_Click:
-
Exit Sub
-
-
Err_Preview_Click:
-
Resume Exit_Preview_Click
-
-
End Sub
-
-
Private Sub Email_Click()
-
'E-Mail selected report. This procedure uses the PrintReports
-
'Sub procedure defined in (General) section of this module.
-
-
DoCmd.SendObject acReport, PrintReports, "RichTextFormat(*.rtf)", "", "email@email.com", "", "MfrReb Report", "This email is being sent from the MR Database", True, ""
-
-
End Sub
-
-
Private Sub Print_Click()
-
'Print selected report. This procedure uses the PrintReports
-
'Sub procedure defined in (General) section of this module.
-
-
PrintReports acNormal
-
End Sub
-
-
Private Sub Preview_Click()
-
'Preview selected report. This procedure uses the PrintReports
-
'Sub procedure defined in (General) section of this module.
-
-
PrintReports acPreview
-
-
End Sub
-
-
6 1745
I think you have several syntax errors in your SendObject statement. Try it this way:
DoCmd.SendObject acSendReport, PrintReports, acFormatRTF," ","email@email.com"," ", "MfrReb Report", "This email is being sent from the MR Database", True
Hi PuppydogBuddy.
First and foremost, thanks for your guidance. It is extremely appreciated!!!!
Now, back to busines... :)
I tried replacing my DoCmd.SendObjects line with your suggestion and I'm still getting the same error. When I put your code in the immediate window, I got a Runtime error 2487.
You wouldn't happen to know any other tricks, work arounds or other suggestions to get this working, would you? :) I know I can have the user just select "Email report" from the Preview window, but I was hoping to not have to go that route.
Thank you again for your assistance.
~Bug
I will look into this further, but here is something I just noticed that may resolve your problem. The error you were getting was "Argument Not Optional". I just notice that your procedure: Sub PrintReports(PrintMode As Integer) requires that you pass PrintMode to the PrintReports procedure. In your SendObject statement you referenced PrintReports, but do not pass PrintMode to the referenced procedure. That is why you are getting the error.
PS: forgot to tell you that an argument can be omitted from a call to a user-defined procedure if it was declared Optional in the procedure declaration. See this link: http://support.microsoft.com/kb/210179
I also had to tweak the original call from a sub to a function and make the PrintMode Optional. But I finally got it to work
THANK YOU THANK YOU THANK YOU!!!
I've said it before, I'll say it again.. thescripts ROCK!!!!!!!!!!!!!!
Here's the code in case anyone else ever runs into this again: - (vb)
-
-
Option Compare Database 'Use database order for string comparisions.
-
Option Explicit 'Requires variables to be declared before they are used
-
-
-
Function PrintReports(Optional PrintMode As Integer)
-
On Error GoTo Err_Preview_Click
-
'This procedure used in Preview, Print, Save and Email Click Sub procedures.
-
'Preview, Print, Save or Email report selected in the SelectReports option group.
-
'Then close the Select Reports Dialog Form.
-
-
Select Case Me!SelectReports
-
Case 1
-
PrintReports = "R_Reasonableness"
-
Case 2
-
PrintReports = "R_Adjustments"
-
Case 3
-
PrintReports = "R_Detail"
-
Case 4
-
PrintReports = "R_PrePaidBalance"
-
Case 5
-
PrintReports = "R_Paid"
-
-
End Select
-
'DoCmd.Close acForm, "F_REPORTS"
-
-
Exit_Preview_Click:
-
Exit Function
-
-
Err_Preview_Click:
-
Resume Exit_Preview_Click
-
-
End Function
-
-
-
-
Private Sub Cmd_Save_Click()
-
'Save selected report. This procedure uses the PrintReports
-
'Function procedure defined in (General) section of this module.
-
-
DoCmd.OutputTo acReport, PrintReports, acFormatRTF, "C:\NetworkFoldersHere\" & PrintReports & ".rtf", True
-
End Sub
-
-
-
Private Sub Email_Click()
-
-
'E-Mail selected report. This procedure uses the PrintReports
-
'Function procedure defined in (General) section of this module.
-
-
-
DoCmd.SendObject acSendReport, PrintReports(), acFormatRTF, "email@email.com", , , "Report: " & PrintReports, "This email is being sent from the MR Database", True
-
End Sub
-
-
-
Private Sub Print_Click()
-
'Print selected report. This procedure uses the PrintReports
-
'Function procedure defined in (General) section of this module.
-
-
DoCmd.OpenReport PrintReports, acNormal
-
End Sub
-
-
Private Sub Preview_Click()
-
'Preview selected report. This procedure uses the PrintReports
-
'Function procedure defined in (General) section of this module.
-
-
DoCmd.OpenReport PrintReports, acPreview
-
-
End Sub
-
-
-
Private Sub Close_Click()
-
DoCmd.Close
-
End Sub
-
-
-
Bug,
You are most welcome. Glad we could help you resolve your problem. Thanks for posting the final solution.
PDB
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Prakash Wadhwani |
last post by:
I have a main Report with 3 sub-reports eg:
Report1 (Main Report) ... SubRpt1, SubRpt2, SubRpt3
SubRpt1, SubRpt2 & SubRpt3 are bound to 3 different tables with a
common relation on a NUMERIC...
|
by: Colin Anderson |
last post by:
I discovered, with great excitement, this article
http://www.davison.uk.net/vb2notes.asp when researching methods for
emailing from Access via Notes. Unfortunatly, when I run this I get a...
|
by: dog |
last post by:
I've seen plenty of articles on this topic but none of them have been
able to solve my problem.
I am working with an Access 97 database on an NT4.0 machine, which has
many Access reports.
I...
|
by: Grasshopper |
last post by:
Hi,
I am automating Access reports to PDF using PDF Writer 6.0. I've
created a DTS package to run the reports and schedule a job to run this
DTS package. If I PC Anywhere into the server on...
|
by: Wayne |
last post by:
I am experiencing an intermittent problem when emailing snapshot
reports using Sendobject. Outlook opens with the snapshot of the
report attached but when I click the "Send" button on the Outlook...
|
by: LP |
last post by:
I am using (trying to) CR version XI, cascading parameters feature works it
asks user to enter params. But if page is resubmitted. It prompts for params
again. I did set...
|
by: cvollberg via AccessMonster.com |
last post by:
Good morning,
I have this procedure that is run that pulls email names that match our
global database and emails reports to automatically to each group of names,
using click yes and Outlook. I...
|
by: Gabryyl |
last post by:
I have several reports being auto-emailed via macros from Access. With
our company's recent upgrades Outlook now pops up a lovely warning
requiring the user to press the Yes button each and every...
|
by: marjbell |
last post by:
I have a Access database of email addresses that I would like to mass
email to customers. Can Access be used through Outlook? or can it just
be done with Access? I know it is possible to use...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |