473,511 Members | 9,908 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 1682
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
missinglinq
3,532 Recognized Expert Specialist
There's absolutely nothing wrong with your original code, comer2k! I just copied it and ran it and it works as it should. I would copy the code from the PrintButton's OnClick event, delete the button, then recreate it.

Welcome to Bytes!

Linq ;0)>
Jun 4 '10 #11

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

Similar topics

7
8823
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
6552
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...
1
1250
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...
3
1101
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?...
5
3451
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...
3
1480
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...
4
1067
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...
1
1301
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...
1
1646
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...
6
2971
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...
0
7251
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,...
0
7148
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...
0
7367
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,...
0
7517
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...
1
5072
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...
0
3230
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...
0
3217
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
790
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
451
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...

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.