472,956 Members | 2,733 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,956 software developers and data experts.

Create List of Report Recordsource Items

I would like to be able to loop through all the report objects in the
database and show the recordsource for each and every report, even if the
report is not actively open. If I know in advance of this analysis that I
all of my reports have queries that start with "qry" I can use the code
below. I wonder if there is a way to do this code if the queries could have
several naming conventions (or no convention at all).

Here is my code for the case of having all the report queries start with the
name "qry"....
This code looks cumbersome. Perhas there is a better way to do this.

Public Sub CheckReports()

Dim db As DAO.Database
Dim cnt As DAO.Container
Dim doc As DAO.Document
Dim prp As DAO.Property
Dim i As Integer
Dim j As Integer
Dim strQryName As String
Dim strCheckThis As String

Set db = CurrentDb
Set cnt = db.Containers("Reports")
Debug.Print

For Each doc In cnt.Documents

Debug.Print "Report Name = " & doc.Name
Debug.Print "Report Property String = " & doc.Properties(9).Value

strCheckThis = doc.Properties(9).Value & " ?"
i = InStr(1, strCheckThis, "qry", 1)
j = InStr(i, strCheckThis, "?", 1)

strQryName = Trim(Mid(strCheckThis, i, j - i))
Debug.Print "Derived Query Name = " & strQryName
Debug.Print "--------------"
Next

On Error Resume Next
Set cnt = Nothing
Set db = Nothing

End Sub

Nov 12 '05 #1
1 3536
On Thu, 05 Feb 2004 04:06:23 GMT, Mike Wiseley wrote:

If you are wanting to get the recordsource of all reports, why be concerned
with what it starts with? Also, try to refer to collection items (property
name in this case) by it's name and not the index number. If you moved this
code to a different version of Access, you may find that property 9 is no
longer the same thing as it was - each version has had some added or
removed!

I would like to be able to loop through all the report objects in the
database and show the recordsource for each and every report, even if the
report is not actively open. If I know in advance of this analysis that I
all of my reports have queries that start with "qry" I can use the code
below. I wonder if there is a way to do this code if the queries could have
several naming conventions (or no convention at all).

Here is my code for the case of having all the report queries start with the
name "qry"....
This code looks cumbersome. Perhas there is a better way to do this.

Public Sub CheckReports()

Dim db As DAO.Database
Dim cnt As DAO.Container
Dim doc As DAO.Document
Dim prp As DAO.Property
Dim i As Integer
Dim j As Integer
Dim strQryName As String
Dim strCheckThis As String

Set db = CurrentDb
Set cnt = db.Containers("Reports")
Debug.Print

For Each doc In cnt.Documents

Debug.Print "Report Name = " & doc.Name
Debug.Print "Report Property String = " & doc.Properties(9).Value

strCheckThis = doc.Properties(9).Value & " ?"
i = InStr(1, strCheckThis, "qry", 1)
j = InStr(i, strCheckThis, "?", 1)

strQryName = Trim(Mid(strCheckThis, i, j - i))
Debug.Print "Derived Query Name = " & strQryName
Debug.Print "--------------"
Next

On Error Resume Next
Set cnt = Nothing
Set db = Nothing

End Sub

--
Mike Storr
veraccess.com
Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: deko | last post by:
I can't move a multi-page report to the last record unless I keep the popup form (that defined it's subreports) open. DoCmd.OpenReport "rptStandard", acViewNormal DoCmd.Close acForm,...
4
by: MSD | last post by:
I am running a report that uses a query as its record source and opens a form collecting beginning and ending item numbers to feed to the query. This works, but now I'm trying to use the result of...
0
by: Brian | last post by:
Hi there, I am working with a report whose recordsource is a query based off of a sql table. We are assigning the recordsource at runtime through code rather than the recordsource property of...
1
by: James Fortune | last post by:
In order to get the records I want on a report I sometimes create a SQL string for the RecordSource and sometimes supply the criteria using the Filter Property. If I use the Filter Property rather...
1
by: CSDunn | last post by:
Hello, In an Access 2003 Project that uses a SQL Server 2000 database as its data source, I am attempting to set the RecordSource property of a sub report called 'RptTeacherHistory2' that appears...
15
by: Richard Hollenbeck | last post by:
I tried to ask this question before on the 14th of January but I never got a reply. I'm still struggling with the problem. I'll try to rephrase the question: I have a crosstab query with rows...
8
by: lauren quantrell | last post by:
When I open an Access form I can have no recordset specified, then in the form's OnOpen event I can do something like: Me.paramaters = "@SomeColumn = 22)" Me.recordsource = "dbo.sproc123" But I...
8
by: | last post by:
hi, i have a form on which a user can choose specific criteria such as dates etc, in order to filter the report that is called from the form. i do this by using the Where section of the...
3
by: kmnotes04 | last post by:
Could anyone tell me how to restrict the date range for items that appear on a report? Old items from previous years appear on the report. I was asked to have only this year's items (and beyond)...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.