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

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

1
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 1097
NeoPa
32,556 Expert Mod 16PB
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
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...
1
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...
2
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...
0
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...
7
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...
4
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...
1
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...
4
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...
1
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...
5
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...
1
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
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: 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: 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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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.