473,320 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Emailing various Reports (via CMD button) from an Option Group

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!

Expand|Select|Wrap|Line Numbers
  1. Sub PrintReports(PrintMode As Integer)
  2.     On Error GoTo Err_Preview_Click
  3.         'This procedure used in Preview_Click and Print_Click Sub procedure.
  4.         'Preview or print report selected in the SelectReports option group.
  5.         'Then close the Select Reports Dialog Form.
  6.  
  7.     Select Case Me!SelectReports
  8.         Case 1
  9.             DoCmd.OpenReport "R_Reasonableness", PrintMode
  10.         Case 2
  11.             DoCmd.OpenReport "R_ADJ", PrintMode
  12.         Case 3
  13.             DoCmd.OpenReport "R_Detail", PrintMode
  14.         Case 4
  15.             DoCmd.OpenReport "R_Detail2", PrintMode
  16.         Case 5
  17.             DoCmd.OpenReport "R_Summary", PrintMode
  18.         Case 6
  19.             DoCmd.OpenReport "R_Summary2", PrintMode
  20.     End Select
  21.     DoCmd.Close acForm, "F_REPORTS"
  22.  
  23. Exit_Preview_Click:
  24.     Exit Sub
  25.  
  26. Err_Preview_Click:
  27.     Resume Exit_Preview_Click
  28.  
  29. End Sub
  30.  
  31. Private Sub Email_Click()
  32. 'E-Mail selected report. This procedure uses the PrintReports
  33. 'Sub procedure defined in (General) section of this module.
  34.  
  35.     DoCmd.SendObject acReport, PrintReports, "RichTextFormat(*.rtf)", "", "email@email.com", "", "MfrReb Report", "This email is being sent from the MR Database", True, ""
  36.  
  37. End Sub
  38.  
  39. Private Sub Print_Click()
  40. 'Print selected report. This procedure uses the PrintReports
  41. 'Sub procedure defined in (General) section of this module.
  42.  
  43.     PrintReports acNormal
  44. End Sub
  45.  
  46. Private Sub Preview_Click()
  47. 'Preview selected report. This procedure uses the PrintReports
  48. 'Sub procedure defined in (General) section of this module.
  49.  
  50.     PrintReports acPreview
  51.  
  52. End Sub
  53.  
  54.  
Mar 28 '08 #1
6 1745
puppydogbuddy
1,923 Expert 1GB
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
Mar 29 '08 #2
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
Mar 29 '08 #3
puppydogbuddy
1,923 Expert 1GB
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.
Mar 29 '08 #4
puppydogbuddy
1,923 Expert 1GB
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
Mar 30 '08 #5
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:


Expand|Select|Wrap|Line Numbers
  1. (vb)
  2.  
  3. Option Compare Database    'Use database order for string comparisions.
  4. Option Explicit 'Requires variables to be declared before they are used
  5.  
  6.  
  7. Function PrintReports(Optional PrintMode As Integer)
  8.     On Error GoTo Err_Preview_Click
  9.         'This procedure used in Preview, Print, Save and Email Click Sub procedures.
  10.         'Preview, Print, Save or Email report selected in the SelectReports option group.
  11.         'Then close the Select Reports Dialog Form.
  12.  
  13.     Select Case Me!SelectReports
  14.         Case 1
  15.             PrintReports = "R_Reasonableness"
  16.         Case 2
  17.             PrintReports = "R_Adjustments"
  18.         Case 3
  19.             PrintReports = "R_Detail"
  20.         Case 4
  21.             PrintReports = "R_PrePaidBalance"
  22.         Case 5
  23.             PrintReports = "R_Paid"
  24.  
  25.     End Select
  26.     'DoCmd.Close acForm, "F_REPORTS"
  27.  
  28. Exit_Preview_Click:
  29.     Exit Function
  30.  
  31. Err_Preview_Click:
  32.     Resume Exit_Preview_Click
  33.  
  34. End Function
  35.  
  36.  
  37.  
  38. Private Sub Cmd_Save_Click()
  39. 'Save selected report. This procedure uses the PrintReports
  40. 'Function procedure defined in (General) section of this module.
  41.  
  42.       DoCmd.OutputTo acReport, PrintReports, acFormatRTF, "C:\NetworkFoldersHere\" & PrintReports & ".rtf", True
  43. End Sub
  44.  
  45.  
  46. Private Sub Email_Click()
  47.  
  48. 'E-Mail selected report. This procedure uses the PrintReports
  49. 'Function procedure defined in (General) section of this module.
  50.  
  51.  
  52.      DoCmd.SendObject acSendReport, PrintReports(), acFormatRTF, "email@email.com", , , "Report: " & PrintReports, "This email is being sent from the MR Database", True
  53. End Sub
  54.  
  55.  
  56. Private Sub Print_Click()
  57. 'Print selected report. This procedure uses the PrintReports
  58. 'Function procedure defined in (General) section of this module.
  59.  
  60.     DoCmd.OpenReport PrintReports, acNormal
  61. End Sub
  62.  
  63. Private Sub Preview_Click()
  64. 'Preview selected report. This procedure uses the PrintReports
  65. 'Function procedure defined in (General) section of this module.
  66.  
  67.     DoCmd.OpenReport PrintReports, acPreview
  68.  
  69. End Sub
  70.  
  71.  
  72. Private Sub Close_Click()
  73. DoCmd.Close
  74. End Sub
  75.  
  76.  
  77.  
Mar 31 '08 #6
puppydogbuddy
1,923 Expert 1GB
Bug,
You are most welcome. Glad we could help you resolve your problem. Thanks for posting the final solution.

PDB
Mar 31 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
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...
5
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...
7
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...
11
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...
2
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...
19
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...
8
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...
3
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...
8
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...
0
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...
0
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...
0
isladogs
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...
0
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...
0
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...
0
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...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
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
0
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.