473,626 Members | 3,304 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Selecting a specific report from a combo box to view/print

1 New Member
I have a report named jobrpt.
It has several reports and I need to be able to select 1 of them and print it off.
I have created a form named mainfrm and have created a combo box I have called ComboReports. In row source this is the code I typed in :
Expand|Select|Wrap|Line Numbers
  1. SELECT [jobtbl].[ID], [jobtbl].[Critical Task Number], [jobtbl].[Job] FROM jobtbl ORDER BY [Critical Task Number] DESC;
Row source Type is set to Tables
I then created a button named PrintReport
The code I typed into the button event is
Expand|Select|Wrap|Line Numbers
  1. Private Sub PrintReport_Click()
  2.     If ComboReports.ListIndex = -1 Then
  3.         MsgBox "Please select a report first"
  4.         Exit Sub
  5.     End If
  6.     DoCmd.OpenReport "jobrpt", acPreview, "[Forms]![mainfrm]![ComboReports]=" & Me.ComboReports
  7. End Sub
The button works but I have to view all the reports instead of just the one I selected. Can anyone help as I am completely new at this?
Mar 29 '19 #1
1 1110
NeoPa
32,568 Recognized Expert Moderator MVP
Let me just start by saying how important it is to post your question carefully. I get that you, as a new user, may be unfamiliar with how to use the site well, including the [CODE] tags, nevertheless, if your post looks a mess and people trip over words that shouldn't be there they are likely to ignore your question and move on to one where the poster put the effort in to read that it at least makes good sense.

I've done what I can to tidy it up for you, but I couldn't make any sense of your first two sentences.
MNesom:
I have a report named jobrpt.
It has several reports and ...
I don't see how a report can have several reports. It doesn't sound like a report with several subreports. That would make sense but wouldn't fit the rest of the question.

However, I may be able to help with your SQL & VBA code. Let's see what we have.

Well, it turns out what I can say at this point is very limited due to the lack of reliable information in your question. At this point I can say that if you want to select something from the ComboBox and use that to filter your report then there are two important points to bear in mind :
  1. You generally filter using the WhereCriteria paramater, which is fourth in the list.
    You're better off using named parameters to avoid just such confusion as found here, but failing that an extra comma (,) is required.
    Don't be confused by the FilterName parameter. That's more complicated and requires a special filtering query.
  2. Numeric, string & Date type values require different handling in SQL (Which is where the format of the WhereCriteria parameter comes from). In this case you seem to be trying to compare the ComboBox result with itself, so that won't work any time, but when you get the field you actually need to use sorted out then it should follow one of the formats below :
    1. "[NumericField]=X"
    2. "[DateField]=#X#"
    3. "[StringField]='X'"
For more details see Literal DateTimes and Their Delimiters (#) and other articles linked therein.
Mar 30 '19 #2

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

Similar topics

0
1153
by: JRT | last post by:
Have a Report with sub report that shows up ok in print preview - looks like it should in preview When I print I get the error "this function is too complex", ok or help and on ok it prints out only the main report part. Sub report doesn't print, yet both reports print by themselves separately. Anyone have any ideas?
1
7037
by: Jason | last post by:
For some reason, most but not all reports printing from an access application our client is using will not print any images on the reports or forms. One report will print the image and data correctly oddly enough. The image header is embedded using the Insert Image feature and not loaded into a database. I can move the image to anywhere in the report and still it will not print out. I've loaded the most recent printer drivers and...
2
2441
by: Bruce Richardson | last post by:
I've read many posts on TheScripts tonight and feel like I'm getting closer to the answer I need. I'm a newbie just trying to accomplish a specific problem. I'm putting on a conference for 250 ham radio operators. I have an Access database with their names and callsigns and such. I have a data entry form from which, once their data is typed in, I want to press one command button and view their specific name badge and a different button to...
0
1479
by: Axeman | last post by:
I have an ASP.NET webapp that needs to view and print several different image formats (JPG, TIFF, BMP, etc.). In addition, it also needs to view/print PDF files. I have successfully implemented the Response.WriteFile(FileName) method to render the various image formats to an Image web control. But, printing this image isn't too slick, as the best I have done so far is printing the entire page (and I just want to print the image). In a...
7
3211
by: jackiefm | last post by:
I have an Access database front end/backend situation. The users create a record in the main form and add subrecords in the subform. When complete, they print a report that is very often multi-page but the report will only print the the subform records which will fit on the first page for some users. Can anyone tell me why that would be?
4
5940
by: heart01 | last post by:
I find myself here again...I am using access 2007 and I have three Reports. What I am thinking I would like to do is have a single list box.combo box? whereby I can select a report and then be able to and or select a date range for that report and then be able to print. I hope this makes sense... so select a specific report Product Outgoing Suppliers
1
5103
bre1603
by: bre1603 | last post by:
I have a multi-user database in Access 2007. One user is having trouble printing a report in print preview. The report is opened from a form using a command button. Both the form and report seem to be working fine. But when she clicks the Print icon in the Access Ribbon while viewing the report (in print preview), a screen shot of the form prints out, instead of the report. No other users seem to be having this problem. And it doesn't...
4
1862
by: Melody Rivera | last post by:
I want to create a drop down box that allows the user to open a specific report. I want to list only certain reports and to list them by a user friendly name (not the back end naming convention that is not meaningful to the user). These reports are already written and run on a query that is already written, the user is not running the report based on criteria just opening the report, preferably in report view not print preview. Any...
1
4288
by: Scorp Scorp | last post by:
Dear All, I designed a report, and bound with some data, the retreived data is 7 coloumns. I set a buttong to open the report in print preview, also to show display the page in landscape. Now on report design view it shows the width of the report to be 22". When the report is displayed, the 6th colomn and the 7th colomn are showed on a new page, moreover the 6th colomn is showed splitted, half of text on one page and the other on the...
5
6771
by: jcrist30 | last post by:
I have a report with several fields/text boxes that are used to determine the values of various report/field totals. Everything is calculating and populating the fields correctly when I view the report in Layout View. However, when I view the report in Print Preview, one of the fields suddenly has a value of 0.00. This field is used in a calculation and acts as the denominator of an equation, so naturally, I get a "division by zero" (#Div0!)...
0
8203
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8711
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8642
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8512
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7203
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4094
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4206
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2630
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1515
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.