473,378 Members | 1,688 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,378 software developers and data experts.

Open and Email Report from Combo Box

7
Hi,

I have over 10 reports from queries that I want to open from a Combo Box. The combo box is working perfect with the name of the reports, I just need to create a button that opens and emails the selected report on the combo box.

I appreciate any help. My experience with access is very limited. Thanks.
Jan 6 '16 #1

✓ answered by zmbd

> What version of Access/Office are you using?

RAM022 Is there a way to change from code builder to macro builder after I started creating an event?
You really shouldn't go back to the macro builder to do this, if what you are doing now in VBA is making a mess of things, I will guarantee that attempting to do this using the macro builder will compound the issues.

RAM022 But when I try to create and additional button and write on the code bulder, it messes up the one tha I already have on the form.
The second button will have its own set of events and associated VBA.

From the code you have now, it appears that you have a command button control named [OpenReport]

I'm guessing that you attempted to add a button named [btnEmailReport] or [btnSendReport]. What is not clear is how you attempted to add the code for this second command button. You MUST do this thru that button [btnEmailReport]'s property-sheet-on_click event. If you attempt this by direct entry into the VBA-Editor then the code you create will not be properly associated with the control (There is a way to do this; however, for beginners or for those rusty with the process I recommend initially avoiding such methods! :) )

>> Here's the catch, when adding a control to a form, depending on which version of Access you are using, how you invoke the builder, and if you have the Wizard enabled, the Wizard can really mess things up by creating an embedded macro and when you go to write the VBA, there's no association between the control and the VBA code. To correct this, you have to back in to the form, find the control, and select "Event Procedure", click on the button with the three dot (ellipses) and then move your VBA script within the form's code module.<<

HVSummer does have one thing right here, we need a clearer picture of what it was that you attempted to do with the second button and by what method you attempted to add the second button (directly from the toolbox, cut-n-paste of the first button, etc...).

=================================
]HVSummerwhat do you mean code builder ? what do you mean macro builder ?
for me, those code/macro are the same thing
PLEASE do NOT confuse people

In MS-Access: unlike in Excel (where your background seems to be):
1) CODE BUILDER is used to create VBA in ACCESS
> A control that has VBA behind the event will show
[Event Procedure]
in the property sheet for that event

2) MACRO BUILDER is used to create ACCESS MACRO SCRIPT
> A control that has an embedded macro behind the event will show
[Embedded Macro]
in the property sheet for that event

In Access development, these two terms: Macro and VBA/Code, are NOT interchangeable.

Of the two, unless creating a sharepoint site, autoexec, and/or autokeys macros - Access VBA is usually more flexible and able to do more than Access Macros - even MS own developers have commented that the Access-Macro was not intended to replace VBA in Access
((MSDN Blogs > Clint Covington: Software design, Microsoft Office Access > Reader question about macros and VBA ))...

]HVSummer== so I know something wrong here..
Sorry, you know no such thing based on this information.

>> When providing direction, we must carefully consider our background and area of expertise before making statements of fact that are not in evidence - unless we commit he grave error of misleading our fellow members.

This has been mentioned to you before by another moderator and myself several times.<<

8 1317
zmbd
5,501 Expert Mod 4TB
RAM022 > outlook or other source?

What is the actual value of the combobox?
If it returns the actual name of the report as its value, NOT THE DISPLAYED NAME, then you can simply use the control's value in the docmd.sendobject (read more) method which is one of the easier methods for sending simple emails. Otherwise, you may have to return the text value or the column value of the control

Remember to include error trapping in case the user cancels the email instead of sending.
Jan 6 '16 #2
hvsummer
215 128KB
@RAM022:
welcome to bytes.com
you can select your report from a query (rowsource of combobox) which sql like this:
Expand|Select|Wrap|Line Numbers
  1. SELECT MSysObjects.Name FROM MsysObjects WHERE (Left$([Name],1)<>"~") AND 
  2. (MSysObjects.Type)= -32764 ORDER BY MSysObjects.Name
if you don't need to automaton a list of email address and your signature prepaired on email, just do as zmbd's suggestion.

but if you need to automaton outlook that carry lot of cases. then you have to give us more detail, then we'll talking about outlook automaton :)
Jan 7 '16 #3
zmbd
5,501 Expert Mod 4TB
hvsummer
That is an "undocumented" feature of on of the access system tables, subject to change without notice by MS.

Let's wait for OP to answer the question about how the combobox is actually designed so that we can provide more bullet proof directions.
Jan 7 '16 #4
RAM022
7
Thanks,

My combo box is is getting the values with a query like HVSUMMER said.

I managed to also get the button to open the report with an Onclick event:

Expand|Select|Wrap|Line Numbers
  1. Private Sub OpenReport_Click()
  2.     DoCmd.OpenReport Forms!ByDirectorates.ComboReports, acViewReport
  3. End Sub
But when I try to create and additional button and write on the code bulder, it messes up the one tha I already have on the form.

Is there a way to change from code builder to macro builder after I started creating an event?

Appreciate all your help.
Jan 7 '16 #5
hvsummer
215 128KB
can you tell us more detail about
Is there a way to change from code builder to macro builder after I started creating an event?
what do you mean code builder ? what do you mean macro builder ?
for me, those code/macro are the same thing == so I know something wrong here..

But when I try to create and additional button and write on the code bulder, it messes up the one tha I already have on the form.
What are you planing to do ? please tell me the purpose, not your previous action...

I could suggest and give you some example if you've given the clean picture.
Jan 8 '16 #6
zmbd
5,501 Expert Mod 4TB
> What version of Access/Office are you using?

RAM022 Is there a way to change from code builder to macro builder after I started creating an event?
You really shouldn't go back to the macro builder to do this, if what you are doing now in VBA is making a mess of things, I will guarantee that attempting to do this using the macro builder will compound the issues.

RAM022 But when I try to create and additional button and write on the code bulder, it messes up the one tha I already have on the form.
The second button will have its own set of events and associated VBA.

From the code you have now, it appears that you have a command button control named [OpenReport]

I'm guessing that you attempted to add a button named [btnEmailReport] or [btnSendReport]. What is not clear is how you attempted to add the code for this second command button. You MUST do this thru that button [btnEmailReport]'s property-sheet-on_click event. If you attempt this by direct entry into the VBA-Editor then the code you create will not be properly associated with the control (There is a way to do this; however, for beginners or for those rusty with the process I recommend initially avoiding such methods! :) )

>> Here's the catch, when adding a control to a form, depending on which version of Access you are using, how you invoke the builder, and if you have the Wizard enabled, the Wizard can really mess things up by creating an embedded macro and when you go to write the VBA, there's no association between the control and the VBA code. To correct this, you have to back in to the form, find the control, and select "Event Procedure", click on the button with the three dot (ellipses) and then move your VBA script within the form's code module.<<

HVSummer does have one thing right here, we need a clearer picture of what it was that you attempted to do with the second button and by what method you attempted to add the second button (directly from the toolbox, cut-n-paste of the first button, etc...).

=================================
]HVSummerwhat do you mean code builder ? what do you mean macro builder ?
for me, those code/macro are the same thing
PLEASE do NOT confuse people

In MS-Access: unlike in Excel (where your background seems to be):
1) CODE BUILDER is used to create VBA in ACCESS
> A control that has VBA behind the event will show
[Event Procedure]
in the property sheet for that event

2) MACRO BUILDER is used to create ACCESS MACRO SCRIPT
> A control that has an embedded macro behind the event will show
[Embedded Macro]
in the property sheet for that event

In Access development, these two terms: Macro and VBA/Code, are NOT interchangeable.

Of the two, unless creating a sharepoint site, autoexec, and/or autokeys macros - Access VBA is usually more flexible and able to do more than Access Macros - even MS own developers have commented that the Access-Macro was not intended to replace VBA in Access
((MSDN Blogs > Clint Covington: Software design, Microsoft Office Access > Reader question about macros and VBA ))...

]HVSummer== so I know something wrong here..
Sorry, you know no such thing based on this information.

>> When providing direction, we must carefully consider our background and area of expertise before making statements of fact that are not in evidence - unless we commit he grave error of misleading our fellow members.

This has been mentioned to you before by another moderator and myself several times.<<
Jan 9 '16 #7
hvsummer
215 128KB
@zmbd and guy:
oh sorry, recently I code a lot on Excel vba so I forgot macro/vbaCode aren't the same thing in Access :D

Macro Script in Access is an built in function that lets user do some simple task, it sometime helpful but usually not really flexible (compare to vba code).

when I mean something wrong, I mean he doing some thing wrong, not the information he provided wrong.

Ok, that's my fault to comment on this.
Jan 9 '16 #8
RAM022
7
Thanks,

I am using Access 2013. I got everything working right now on a pop up form from my main form. It looks like this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub EmailReport_Click()
  2. On Error GoTo EmailReport_Click_Err
  3.  
  4. DoCmd.SendObject acReport, Forms!ByDirectorates.ComboReports, "PDFFormat(*.pdf)", "", "", "", "", "", True, ""
  5.  
  6.  
  7. EmailReport_Click_Exit:
  8.     Exit Sub
  9.  
  10. EmailReport_Click_Err:
  11.  
  12.     Resume EmailReport_Click_Exit
  13. End Sub
  14.  
  15. Private Sub OpenReport_Click()
  16. DoCmd.OpenReport Forms!ByDirectorates.ComboReports, acViewReport
  17. End Sub
  18.  
Everything is working fine, with error trapping and on pdf format like I wanted it. I just might have to change the way my combo box is getting its values from in case Microsoft changes something in the MSysObjects table like you mentioned.

I appreciate all your help.

Now I have a different question but I guess I will start a differente thread not to get this one too crazy. Thanks again.
Jan 20 '16 #9

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

Similar topics

6
by: dog | last post by:
Does anyone know how to use a hyperlink in MS Access (I'm using 97) to open a report or form within the same database? I have a form in my database, I have put a label on it, some text, and when...
6
by: erick-flores | last post by:
Hello, I want to make a report for a single compressor. Instead of showing a report for all the compressors. I would like to place a button in the compressor form, so whenever I want to display a...
2
by: Bob | last post by:
I have a regular C# form with a button on it. I want to click the button and open the report. What code do I need to open the report? Thanks-in-advance. Bob
0
by: mike11d11 | last post by:
I have a form with a dataset that contains account records in one table and another table that contains transactions for accounts that are in the other table. I'm trying to create a report based...
0
by: Kelii | last post by:
Evenlater, Yeah, I don't open the report in preview mode when I setup my recordsource, filters, or sorts. Before I give my solution, I would say that your code will be simpler if you drop the...
3
by: Naushad | last post by:
Hi All, I am trying to open the report conditionally from the dialogue box form. In the form there are three field. cboEmployees StartDate EndDate I have used these field in criteria to...
0
by: sarvmardan | last post by:
how to open a report in access containing filtered data using two combo boxes on form and a button to click. let i have two fields and other is . two comboboxes are combo11 and combo9. plz post...
6
by: SusanK4305 | last post by:
Here are my two code for the Report that will be opened. This Report is in Access and is name rpt1, It isn't opening like it should. Please Help... Thank you. Private Sub cmdApplyFilter_Click() ...
0
by: Jason Hamilton | last post by:
Hey all, Okay, so here's what's going on. I have a customer who wants me to push the reports generated by MS Access to his corporate website on demand. I have most of this problem solved (by...
0
by: baba | last post by:
I like to open a report as a pivot chart from my query. How to open a report by making the default view of report as pivot chart?. I am able to manually create a pivot chart by clicking pivot...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.