473,587 Members | 2,496 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

List of reports to preview.

5 New Member
Hi Guys. Am a bit stuck. Need some help is poss.

I have an unbound combo box in a form that I want to list ALL reports in.

Ive found multiple examples on the site but cant get them to work.

My combo bow is called ComboReports and I have set Row Source Type to Table/Query. In the RowSource box I have input

Expand|Select|Wrap|Line Numbers
  1. SELECT [MSysObjects].[Name] FROM MsysObjects WHERE (Left$([Name],1)<>"~") And ([MSysObjects].[Type])=-32764 ORDER BY [MSysObjects].[Name]; 
This part works fantastic.

The part thats causing an issue is my button. I want it to open the selected report on click but its not working.

My button is called PrintReport and I have the following event procedure for on click

Expand|Select|Wrap|Line Numbers
  1. Private Sub PrintReport_Click() 
  2.    If Not IsNull(ComboReports) And ComboReports <> "" Then 
  3.      DoCmd.OpenReport ComboReports, acViewPreview  ' use acNormal to print without preview 
  4.    Else 
  5.      MsgBox ("You Must First Select a Report To Print!") 
  6.      ComboReports.SetFocus 
  7.    End If 
  8.    ComboReports = "" 
  9. End Sub 
when I press my button nothing happens. I cant work out whats wrong, could it be something in the form? or is the button event wrong?

Thanks
Jun 3 '10 #1
10 1697
patjones
931 Recognized Expert Contributor
You can use this to populate the combo box:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2.  
  3. Dim oAccess As AccessObject
  4.  
  5. Me.ComboReports.RowSourceType = "Value List"
  6.  
  7. For Each oAccess In CurrentProject.AllReports
  8.     Me.ComboReports.AddItem oAccess.Name
  9. Next oAccess
  10.  
  11. Set oAccess = Nothing
  12.  
  13. End Sub

To open the report after picking it from the list:

Expand|Select|Wrap|Line Numbers
  1. Private Sub ComboReports_AfterUpdate()
  2.  
  3. DoCmd.OpenReport Me.ComboReports, acViewPreview
  4.  
  5. End Sub

Let me know how it works.

Pat
Jun 3 '10 #2
comer2k
5 New Member
when I put the first string of code in the form rather than the text I get no reports in my combo box.

I also attempted to only use the second string of code with my original box and that brings up an error saying "Charactors found ant the end of SQL statement.
Jun 3 '10 #3
patjones
931 Recognized Expert Contributor
The first set of code, from lines 3 to 11, is meant to be put in the On Open event of your form. The second set of code (line 3) goes in the After Update event of your combo box; this will cause the report to open in a preview as soon as it is selected from the list. This eliminates the need for a command button and the logic that goes into checking whether the user made a selection from the combo box yet.

Pat
Jun 3 '10 #4
comer2k
5 New Member
Hi,

Ive put lines 3-11 in the on open event and my reports now show in the combo box. However second part of the code still wont open a preview. Its in the correct box but I dont know why it wont open. Can there be something in the form settings stopping a preview?
Jun 3 '10 #5
patjones
931 Recognized Expert Contributor
Does anything at all happen when you make the selection from the combo box? Not even an error?
Jun 3 '10 #6
comer2k
5 New Member
No nothing. The selected report looks like it greys out for a second (as if it confirms its the selection) but after that nothing.
Jun 3 '10 #7
patjones
931 Recognized Expert Contributor
Can you post your code? Thanks.
Jun 3 '10 #8
comer2k
5 New Member
Hi

Its
Expand|Select|Wrap|Line Numbers
  1. Private Sub ComboReports___AfterUpdate()
  2. DoCmd.OpenReport Me.ComboReports, acViewPreview
  3. End Sub
Jun 4 '10 #9
patjones
931 Recognized Expert Contributor
One thing that sticks out is that you have too many underscores in the subroutine declaration:

Change

Expand|Select|Wrap|Line Numbers
  1. Private Sub ComboReports___AfterUpdate()

to

Expand|Select|Wrap|Line Numbers
  1. Private Sub ComboReports_AfterUpdate()

Pat
Jun 4 '10 #10

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

Similar topics

7
8841
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 want my users to be able to select a report, click on a command button on a form, which will then automatically create the report as a pdf file and...
11
6579
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 where the job is running, the job runs sucessfully, PDF files got generated, everything is good. If I scheduled the job to run at the time that I am...
1
1257
by: spamworks | last post by:
Is that something I control in Access or is it a problem with the printer? Can I, in code, force it to print normally sized? If the user prints it a 2nd time, it prints normal size. If you need more info, please post and let me know. Thanks. (Oh, and it's not all users, just 1 or 2. Windows 2000.)
3
1103
by: Alberto | last post by:
When the user print a report from the crystal reports preview, the report it's full of strange characters but if we export it to word or pdf and then we print it, we can read it fine. Why? Thank you
5
3454
by: Alberto | last post by:
When the user print a report from the crystal reports preview, the report it's full of strange characters but if we export it to word or pdf and then we print it, we can read it fine. The font I'm using in the report is Times new roman. Why? Thank you
3
1485
by: MJP | last post by:
I've managed to preview multiple instances of a report, all with different filters. The problem now occurs when I try to print these reports or export as snapshot etc. If you try to print any of the reports it only prints the first report that was created. Are there any workarounds for this or is this just a limitation of access?
4
1073
by: tofu.captain | last post by:
I'm using Visual Studio .NET 2005 with a C# Web Application project. I have an ASPX page that uses a MasterPage file for a general site layout. That works just fine, but when I run a compile of the ASPX page (say default.aspx) with something like: <asp:Label id="lblFoo" runat="server" /> and have it's codebehind have: protected void...
1
1311
by: hafizmzahid | last post by:
asalm o alikum all i am using developer 2000 version 6. i have developed reports using this version. now i want to build customise menu bar and tool bar for reports preview or when i will call report from the forms. any body can know this issue please help me. ok
1
1659
by: ncsthbell | last post by:
I have a form that allows the users to select/highlight reports in a list that they want to preview/print. There are about 30 reports and when they only select a few it works fine. However, if they select all the reports to preview, then about 1/2 way through it gives a 3014 error (can not open any more tables). The reports all have queries in...
6
2977
by: Peter | last post by:
I have a WebService which returns a List of RunningReport class How do I read this XML data on the client side. How do I convert List<RunningReportfrom the WebService side to List<RunningReporton the client side I have tried the following: List<RunningReportreportList = null; localhost.ReportService localrs = new...
0
7923
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8216
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. ...
0
8349
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...
1
7974
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8221
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...
0
6629
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...
1
5719
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5395
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1455
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.