Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: How Can I Display a List of Access Reports in a Web Page


Message #1 by "Mark A. Laughlin" <mlaughlin@e...> on Fri, 20 Jul 2001 17:32:10
Basically, I want to display a list of Access Reports in a drop down list. 

Is there a way to submit a query form an ASP page to product a list or 

Reports for a particular database?



Mark A. Laughlin

http://www.eoffshore.com/mlaughlin
Message #2 by "Richard Lobel" <richard@a...> on Fri, 20 Jul 2001 11:26:52 -0700
You can loop through the reports collection to make a string for your

combo box.

Example:

Combobox.recordsourcetype="ValueList" 'This tells Access to use a string

you will supply

Dim I as integer

Dim strList as string

For I = 0 to Reports.Count-1

	strList = strList & Reports(i).name & ","

Next I

ComboBox.RecordSource=strList



Good Luck,

Richard Lobel







Message #3 by "Yehuda Rosenblum" <yehuda@i...> on Fri, 20 Jul 2001 22:14:30
Mark,



I know this is really an ASP answer and not Access, but you could do: 



Dim MyVariable, NumReports, i

set MyVariable = CreateObject("Access.Application")



MyVariable.OpenCurrentDatabase "c:\eDocsClient.mdb", False

    NumReports = MyVariable.Reports.Count



    For i = 1 To NumReports

        response.write MyVariable.Reports.Item(i).Name

    Next

> Basically, I want to display a list of Access Reports in a drop down 

list. 

> Is there a way to submit a query form an ASP page to product a list or 

> Reports for a particular database?

> 

> Mark A. Laughlin

> http://www.eoffshore.com/mlaughlin
Message #4 by "Mark A. Laughlin" <mlaughlin@e...> on Mon, 23 Jul 2001 21:43:02
Thanks for the guidance.



Because I'm working with an ADP file, I found that I had to 

use "OpenAccessProject". 



Attempts to count Reports repeatedly resulted in a count of 0. I tried 

forms, which only returned a count of 1, although I was able to return the 

name of ONE form by hard coding the index number, if I allowed the loop to 

be in control (or tried an index value of anything other than 1), I got 

index out of range errors. 



MyVariable.OpenAccessProject "c:\smh\testDatabase.adp", False

NumForms = MyVariable.Forms.Count

Response.Write(NumForms)  ' RETURNS 0 FOR REPORTS AND 1 FOR FORMS

For i = 0 To NumForms-1   

   response.write MyVariable.Forms.Item(0).Name  ' RETURNS NAME OF ONE FORM

Next



Anyone have any ideas how I can get this list of reports to work?



Mark A. Laughlin



> Dim MyVariable, NumReports, i

> set MyVariable = CreateObject("Access.Application")

> 

> MyVariable.OpenCurrentDatabase "c:\eDocsClient.mdb", False

>     NumReports = MyVariable.Reports.Count

> 

>     For i = 1 To NumReports

>         response.write MyVariable.Reports.Item(i).Name

>     Next

Message #5 by "Yehuda Rosenblum" <Yehuda@I...> on Mon, 23 Jul 2001 17:05:27 -0400
Mark,



I believe the first form is 1 to whatever.  Try doing For I =3D1 to

NumForms



-----Original Message-----

From: Mark A. Laughlin [mailto:mlaughlin@e...]

Sent: Monday, July 23, 2001 5:43 PM

To: Access

Subject: [access] Re: How Can I Display a List of Access Reports in a

Web Page





Thanks for the guidance.



Because I'm working with an ADP file, I found that I had to

use "OpenAccessProject".



Attempts to count Reports repeatedly resulted in a count of 0. I tried

forms, which only returned a count of 1, although I was able to return

the

name of ONE form by hard coding the index number, if I allowed the loop

to

be in control (or tried an index value of anything other than 1), I got

index out of range errors.



MyVariable.OpenAccessProject "c:\smh\testDatabase.adp", False NumForms 

=3D

MyVariable.Forms.Count

Response.Write(NumForms)  ' RETURNS 0 FOR REPORTS AND 1 FOR FORMS

For i =3D 0 To NumForms-1  

   response.write MyVariable.Forms.Item(0).Name  ' RETURNS NAME OF ONE

FORM Next



Anyone have any ideas how I can get this list of reports to work?



Mark A. Laughlin



> Dim MyVariable, NumReports, i

> set MyVariable =3D CreateObject("Access.Application")

>

> MyVariable.OpenCurrentDatabase "c:\eDocsClient.mdb", False

>     NumReports =3D MyVariable.Reports.Count

>

>     For i =3D 1 To NumReports

>         response.write MyVariable.Reports.Item(i).Name

>     Next

Message #6 by "Pardee, Roy E" <roy.e.pardee@l...> on Mon, 23 Jul 2001 14:09:55 -0700
This is unsupported, but you can query a system table for a list of reports.

Dig it:



SELECT MSysObjects.Name

FROM MSysObjects

WHERE (((MSysObjects.Type)=-32764));



HTH,



-Roy



-----Original Message-----

From: Mark A. Laughlin [mailto:mlaughlin@e...]

Sent: Monday, July 23, 2001 2:43 PM

To: Access

Subject: [access] Re: How Can I Display a List of Access Reports in a

Web Page





Thanks for the guidance.



Because I'm working with an ADP file, I found that I had to 

use "OpenAccessProject". 



Attempts to count Reports repeatedly resulted in a count of 0. I tried 

forms, which only returned a count of 1, although I was able to return the 

name of ONE form by hard coding the index number, if I allowed the loop to 

be in control (or tried an index value of anything other than 1), I got 

index out of range errors. 



MyVariable.OpenAccessProject "c:\smh\testDatabase.adp", False

NumForms = MyVariable.Forms.Count

Response.Write(NumForms)  ' RETURNS 0 FOR REPORTS AND 1 FOR FORMS

For i = 0 To NumForms-1   

   response.write MyVariable.Forms.Item(0).Name  ' RETURNS NAME OF ONE FORM

Next



Anyone have any ideas how I can get this list of reports to work?



Mark A. Laughlin



> Dim MyVariable, NumReports, i

> set MyVariable = CreateObject("Access.Application")

> 

> MyVariable.OpenCurrentDatabase "c:\eDocsClient.mdb", False

>     NumReports = MyVariable.Reports.Count

> 

>     For i = 1 To NumReports

>         response.write MyVariable.Reports.Item(i).Name

>     Next

Message #7 by Brian Skelton <brian.skelton@b...> on Mon, 23 Jul 2001 23:04:10 +0100
Hi Mark



The Reports (and Forms) collections will only return objects for those 

reports (and forms) that are currently open.



To get a list of all reports (or forms!) in your database you need to 

use the Document collection. Have a look in help. If that's not helpful, 

I can probably dig out some code (DAO only) for you to canibalise.



-BDS



-----Original Message-----

From:	Mark A. Laughlin [SMTP:mlaughlin@e...]

Sent:	23 July 2001 22:43

To:	Access

Subject:	[access] Re: How Can I Display a List of Access Reports in a 

Web Page



Thanks for the guidance.



Because I'm working with an ADP file, I found that I had to

use "OpenAccessProject".



Attempts to count Reports repeatedly resulted in a count of 0. I tried

forms, which only returned a count of 1, although I was able to return 

the

name of ONE form by hard coding the index number, if I allowed the loop 

to

be in control (or tried an index value of anything other than 1), I got

index out of range errors.



MyVariable.OpenAccessProject "c:\smh\testDatabase.adp", False

NumForms =3D MyVariable.Forms.Count

Response.Write(NumForms)  ' RETURNS 0 FOR REPORTS AND 1 FOR FORMS

For i =3D 0 To NumForms-1  

   response.write MyVariable.Forms.Item(0).Name  ' RETURNS NAME OF ONE 

FORM

Next



Anyone have any ideas how I can get this list of reports to work?



Mark A. Laughlin



> Dim MyVariable, NumReports, i

> set MyVariable =3D CreateObject("Access.Application")

>

> MyVariable.OpenCurrentDatabase "c:\eDocsClient.mdb", False

>     NumReports =3D MyVariable.Reports.Count

>

>     For i =3D 1 To NumReports

>         response.write MyVariable.Reports.Item(i).Name

>     Next

Message #8 by Brian Skelton <brian.skelton@b...> on Tue, 24 Jul 2001 00:13:46 +0100
...easier to find than I thought.



Function FindAllReports() As Variant

'Returns an array of all the report names in the database

Dim myDb As Database

Dim ctrReports As Container

Dim docReports As Document

Dim varReturn() As Variant

Dim intCount As Integer

Const ERR_SUBSCRIPT =3D 9

On Error GoTo errFindAllReports



    Set myDb =3D CurrentDb

    ' Return reference to Modules container.

    Set ctrReports =3D myDb.Containers("Reports")

    'Size the array to hold the names

    ReDim varReturn(0 To ctrReports.Documents.Count - 1)

   

    intCount =3D 0

    'Cycle through the reports and capture their names

    For Each docReports In ctrReports.Documents

        varReturn(intCount) =3D docReports.Name

        intCount =3D intCount + 1

    Next

   

    FindAllReports =3D varReturn

   

exitFindAllReports:

    Set ctrReports =3D Nothing

    Exit Function

   

errFindAllReports:

    If Err.Number =3D ERR_SUBSCRIPT Then 'There are no reports in the 

database

        FindAllReports =3D Null

        Err =3D 0

        Resume exitFindAllReports

    Else

        MsgBox Err.Description

        Err =3D 0

        Resume exitFindAllReports

    End If

   

End Function



-----Original Message-----

From:	Brian Skelton [SMTP:brian.skelton@b...]

Sent:	23 July 2001 23:04

To:	Access

Subject:	[access] Re: How Can I Display a List of Access Reports in a 

Web Page



Hi Mark



The Reports (and Forms) collections will only return objects for those 

reports (and forms) that are currently open.



To get a list of all reports (or forms!) in your database you need to 

use the Document collection. Have a look in help. If that's not helpful, 

I can probably dig out some code (DAO only) for you to canibalise.



-BDS



-----Original Message-----

From:	Mark A. Laughlin [SMTP:mlaughlin@e...]

Sent:	23 July 2001 22:43

To:	Access

Subject:	[access] Re: How Can I Display a List of Access Reports in a 

Web Page



Thanks for the guidance.



Because I'm working with an ADP file, I found that I had to

use "OpenAccessProject".



Attempts to count Reports repeatedly resulted in a count of 0. I tried

forms, which only returned a count of 1, although I was able to return 

the

name of ONE form by hard coding the index number, if I allowed the loop 

to

be in control (or tried an index value of anything other than 1), I got

index out of range errors.



MyVariable.OpenAccessProject "c:\smh\testDatabase.adp", False

NumForms =3D MyVariable.Forms.Count

Response.Write(NumForms)  ' RETURNS 0 FOR REPORTS AND 1 FOR FORMS

For i =3D 0 To NumForms-1  

   response.write MyVariable.Forms.Item(0).Name  ' RETURNS NAME OF ONE 

FORM

Next



Anyone have any ideas how I can get this list of reports to work?



Mark A. Laughlin



> Dim MyVariable, NumReports, i

> set MyVariable =3D CreateObject("Access.Application")

>

> MyVariable.OpenCurrentDatabase "c:\eDocsClient.mdb", False

>     NumReports =3D MyVariable.Reports.Count

>

>     For i =3D 1 To NumReports

>         response.write MyVariable.Reports.Item(i).Name

>     Next

Message #9 by John Fejsa <John.Fejsa@h...> on Wed, 25 Jul 2001 08:13:32 +1000
You can also get report names quickly by creating the following query in 

query view to list ALL reports and then read the names from the query.



SELECT MSysObjects.Name

FROM MSysObjects

WHERE (((MSysObjects.Type)=3D-32764)); '32764 indicates a report



Another method for your collection...



________________________________________



>>> brian.skelton@b... 24/07/2001 9:13:46 >>>

...easier to find than I thought.



Function FindAllReports() As Variant

'Returns an array of all the report names in the database

Dim myDb As Database

Dim ctrReports As Container

Dim docReports As Document

Dim varReturn() As Variant

Dim intCount As Integer

Const ERR_SUBSCRIPT =3D 9

On Error GoTo errFindAllReports



    Set myDb =3D CurrentDb

    ' Return reference to Modules container.

    Set ctrReports =3D myDb.Containers("Reports")

    'Size the array to hold the names

    ReDim varReturn(0 To ctrReports.Documents.Count - 1)

   

    intCount =3D 0

    'Cycle through the reports and capture their names

    For Each docReports In ctrReports.Documents

        varReturn(intCount) =3D docReports.Name

        intCount =3D intCount + 1

    Next

   

    FindAllReports =3D varReturn

   

exitFindAllReports:

    Set ctrReports =3D Nothing

    Exit Function

   

errFindAllReports:

    If Err.Number =3D ERR_SUBSCRIPT Then 'There are no reports in the 

database

        FindAllReports =3D Null

        Err =3D 0

        Resume exitFindAllReports

    Else

        MsgBox Err.Description

        Err =3D 0

        Resume exitFindAllReports

    End If

   

End Function



-----Original Message-----

From: Brian Skelton [SMTP:brian.skelton@b...]

Sent: 23 July 2001 23:04

To: Access

Subject: [access] Re: How Can I Display a List of Access Reports in 

a Web Page



Hi Mark



The Reports (and Forms) collections will only return objects for those 

reports (and forms) that are currently open.



To get a list of all reports (or forms!) in your database you need to use 

the Document collection. Have a look in help. If that's not helpful, I can 

probably dig out some code (DAO only) for you to canibalise.



-BDS



-----Original Message-----

From: Mark A. Laughlin [SMTP:mlaughlin@e...]

Sent: 23 July 2001 22:43

To: Access

Subject: [access] Re: How Can I Display a List of Access Reports in 

a Web Page



Thanks for the guidance.



Because I'm working with an ADP file, I found that I had to

use "OpenAccessProject".



Attempts to count Reports repeatedly resulted in a count of 0. I tried

forms, which only returned a count of 1, although I was able to return 

the

name of ONE form by hard coding the index number, if I allowed the loop 

to

be in control (or tried an index value of anything other than 1), I got

index out of range errors.



MyVariable.OpenAccessProject "c:\smh\testDatabase.adp", False

NumForms =3D MyVariable.Forms.Count

Response.Write(NumForms)  ' RETURNS 0 FOR REPORTS AND 1 FOR FORMS

For i =3D 0 To NumForms-1  

   response.write MyVariable.Forms.Item(0).Name  ' RETURNS NAME OF ONE 

FORM

Next



Anyone have any ideas how I can get this list of reports to work?



Mark A. Laughlin



> Dim MyVariable, NumReports, i

> set MyVariable =3D CreateObject("Access.Application")

>

> MyVariable.OpenCurrentDatabase "c:\eDocsClient.mdb", False

>     NumReports =3D MyVariable.Reports.Count

>

>     For i =3D 1 To NumReports

>         response.write MyVariable.Reports.Item(i).Name

>     Next


  Return to Index