Open reports?

  • Thread starter Thread starter Henro
  • Start date Start date
H

Henro

I need code that opens a view with all reports available in the database. Is
this possible? Is there also code that will print ALL available reports? I
have one now that prints a lot of reports using a macro but as soon as a
report is added, renamed or removed in any way this generates error's and is
very demanding in maintenance.
I would like code that prints all reports that are available. Is this
possible?

There is only one specific that needs to be printed first ALWAYS..

Any suggestion is appreciated!

Grtz Henro
 
You didn't say what version of Access you're using, but if it's A2000 or
above you can iterate the CurrentProject.AllReports collection and present
the report names in listbox:

dim varObj As AccessObject
dim strName as string

For Each varObj In CurrentProject.AllReports
strName = varObj & ";" & strname
Next

Me.NameOfYourListbox.RowSource = strname

Your listbox must be set to .RowSourceType = VAlue List

If you want to print all selected reports, just loop through the
..ItemsSelected collection of your listbox (see online help for an example of
how to do this) and print each report using the DoCmd.OpenReport method.
 
It is Acc2000, i see that I neglected to report that.

Your solution is what I was looking for. Thank you.

Grtz Henro
 
How about a query ...

SELECT Name FROM MsysObjects WHERE MsysObjects.Type=-32764

This will have an advantage over creating a string of report names, since
there is a limit to the size of a value list string on a control RowSource
property. It may be large, but I hit it once. :-)
 
Henro said:
I need code that opens a view with all reports available in the database. Is
this possible? Is there also code that will print ALL available reports? I
have one now that prints a lot of reports using a macro but as soon as a
report is added, renamed or removed in any way this generates error's and is
very demanding in maintenance.
I would like code that prints all reports that are available. Is this
possible?

There is only one specific that needs to be printed first ALWAYS..

Any suggestion is appreciated!

Grtz Henro
 
I like this solution but if I try to make a listbox it tell's me there are
'no valid fields to select'?
<= translated from Dutch, I hope that makes sense...............

Grtz Henro
 
I had to make the systables visible and now it works. I have a listbox
containing all reports but nothing happems if I doubleclick one? How do I
get the report (or multiple if selected) to open on doubleclick?

Grtz Henro
 
I guess this is not right?

Dim ToPrint

ToPrint = MyReports.ItemsSelected

DoCmd.OpenReport ToPrint

MyReports is the name of the object
 
I got it working in a way that saved me a hell of a lot of time!


I thank you both very very much!

Grtz Henro
 
Back
Top