473,503 Members | 11,735 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Automating report in a different MDB ( Question #2 )

I need to automate a report in a different database (and thank yous to Terry
Kreft for pointing me in the right direction).

below is the code with the one line that does not work, marked: 'Does not
Work'

It appears that the type of object returned from the "AllReports" collection
is not a report object.
=>> I need it to be an object of type report.
'for automating remote report
Dim App As Access.Application
Dim myDb As Database
Dim dbs As Object
Dim RPT_Copy As Access.Report
Dim strDBPath As String
Dim obj As Object
Const REPORT_NAME_Copy = "MyReport"

strDBPath = Application.CurrentProject.Path & "\MyData.mdb"
Set App = New Access.Application

With App
.OpenCurrentDatabase strDBPath, False
Set myDb = .CurrentDb
Set dbs = App.CurrentProject
For Each obj In dbs.AllReports
If obj.Name = REPORT_NAME_Copy Then

'Does not Work - the objects are different types
Set RPT = dbs.AllReports(REPORT_NAME_Copy)
'end of Does not Work

If RPT Is Nothing Then
OpenReport = False
On Error Resume Next
myDb.Close
Set myDb = Nothing
App.Quit acQuitSaveNone
Set App = Nothing
Exit For
Else
OpenReport = True
Exit For
End If
End If
Next obj
End With

Thank you,
John Bickmore
www.BicycleCam.com
www.Feed-Zone.com
Nov 12 '05 #1
7 2614
I haven't used this process with Access XP, but in Access 97 you
could use a similar method to get the name of a report from the
Reports Container, as you have with the AllReports object.

The problem is, you can't set a report object to it, since it isn't
open. All you have is a name. Add this line ...

DoCmd.OpenReport "[report name]",acViewDesign,,,acHidden

Once it's opened, then the next line, where you set a report object
to it, will work.
--

Danny J. Lesandrini
dl*********@hotmail.com
http://amazecreations.com
"xzzy" <mr********@comcast.net> wrote in message news:6jJBb.356152$275.1163344@attbi_s53...
I need to automate a report in a different database (and thank yous to Terry
Kreft for pointing me in the right direction).

below is the code with the one line that does not work, marked: 'Does not
Work'

It appears that the type of object returned from the "AllReports" collection
is not a report object.
=>> I need it to be an object of type report.
'for automating remote report
Dim App As Access.Application
Dim myDb As Database
Dim dbs As Object
Dim RPT_Copy As Access.Report
Dim strDBPath As String
Dim obj As Object
Const REPORT_NAME_Copy = "MyReport"

strDBPath = Application.CurrentProject.Path & "\MyData.mdb"
Set App = New Access.Application

With App
.OpenCurrentDatabase strDBPath, False
Set myDb = .CurrentDb
Set dbs = App.CurrentProject
For Each obj In dbs.AllReports
If obj.Name = REPORT_NAME_Copy Then

'Does not Work - the objects are different types
Set RPT = dbs.AllReports(REPORT_NAME_Copy)
'end of Does not Work

If RPT Is Nothing Then
OpenReport = False
On Error Resume Next
myDb.Close
Set myDb = Nothing
App.Quit acQuitSaveNone
Set App = Nothing
Exit For
Else
OpenReport = True
Exit For
End If
End If
Next obj
End With

Thank you,
John Bickmore
www.BicycleCam.com
www.Feed-Zone.com

Nov 12 '05 #2
thanks, but setting the report object is the problem

John Bickmore
www.BicycleCam.com
www.Feed-Zone.com

"Danny J. Lesandrini" <dl*********@hotmail.com> wrote in message
news:br***********@ID-82595.news.uni-berlin.de...
I haven't used this process with Access XP, but in Access 97 you
could use a similar method to get the name of a report from the
Reports Container, as you have with the AllReports object.

The problem is, you can't set a report object to it, since it isn't
open. All you have is a name. Add this line ...

DoCmd.OpenReport "[report name]",acViewDesign,,,acHidden

Once it's opened, then the next line, where you set a report object
to it, will work.
--

Danny J. Lesandrini
dl*********@hotmail.com
http://amazecreations.com
"xzzy" <mr********@comcast.net> wrote in message

news:6jJBb.356152$275.1163344@attbi_s53...
I need to automate a report in a different database (and thank yous to Terry Kreft for pointing me in the right direction).

below is the code with the one line that does not work, marked: 'Does not Work'

It appears that the type of object returned from the "AllReports" collection is not a report object.
=>> I need it to be an object of type report.
'for automating remote report
Dim App As Access.Application
Dim myDb As Database
Dim dbs As Object
Dim RPT_Copy As Access.Report
Dim strDBPath As String
Dim obj As Object
Const REPORT_NAME_Copy = "MyReport"

strDBPath = Application.CurrentProject.Path & "\MyData.mdb"
Set App = New Access.Application

With App
.OpenCurrentDatabase strDBPath, False
Set myDb = .CurrentDb
Set dbs = App.CurrentProject
For Each obj In dbs.AllReports
If obj.Name = REPORT_NAME_Copy Then

'Does not Work - the objects are different types
Set RPT = dbs.AllReports(REPORT_NAME_Copy)
'end of Does not Work

If RPT Is Nothing Then
OpenReport = False
On Error Resume Next
myDb.Close
Set myDb = Nothing
App.Quit acQuitSaveNone
Set App = Nothing
Exit For
Else
OpenReport = True
Exit For
End If
End If
Next obj
End With

Thank you,
John Bickmore
www.BicycleCam.com
www.Feed-Zone.com


Nov 12 '05 #3
Did you understand my answer? Is your problem solved already?

I agree, the problem is setting the report object, but the reason
it's a problemis because there is nothing to set it to. Your report
class doesn't exist, until you open the report, so you can't set the
report object equal to it without an error.

Did you try my suggestion, or are you dismissing it out of hand
because it seems incorrect to you?
--
Danny J. Lesandrini
dl*********@hotmail.com
http://amazecreations.com
"xzzy" <mr********@comcast.net> wrote ...
thanks, but setting the report object is the problem

John Bickmore
www.BicycleCam.com
www.Feed-Zone.com

"Danny J. Lesandrini" <dl*********@hotmail.com> wrote in message
news:br***********@ID-82595.news.uni-berlin.de...
I haven't used this process with Access XP, but in Access 97 you
could use a similar method to get the name of a report from the
Reports Container, as you have with the AllReports object.

The problem is, you can't set a report object to it, since it isn't
open. All you have is a name. Add this line ...

DoCmd.OpenReport "[report name]",acViewDesign,,,acHidden

Once it's opened, then the next line, where you set a report object
to it, will work.
--

Danny J. Lesandrini
dl*********@hotmail.com
http://amazecreations.com
"xzzy" <mr********@comcast.net> wrote in message

news:6jJBb.356152$275.1163344@attbi_s53...
I need to automate a report in a different database (and thank yous to Terry Kreft for pointing me in the right direction).

below is the code with the one line that does not work, marked: 'Does not Work'

It appears that the type of object returned from the "AllReports" collection is not a report object.
=>> I need it to be an object of type report.
'for automating remote report
Dim App As Access.Application
Dim myDb As Database
Dim dbs As Object
Dim RPT_Copy As Access.Report
Dim strDBPath As String
Dim obj As Object
Const REPORT_NAME_Copy = "MyReport"

strDBPath = Application.CurrentProject.Path & "\MyData.mdb"
Set App = New Access.Application

With App
.OpenCurrentDatabase strDBPath, False
Set myDb = .CurrentDb
Set dbs = App.CurrentProject
For Each obj In dbs.AllReports
If obj.Name = REPORT_NAME_Copy Then

'Does not Work - the objects are different types
Set RPT = dbs.AllReports(REPORT_NAME_Copy)
'end of Does not Work

If RPT Is Nothing Then
OpenReport = False
On Error Resume Next
myDb.Close
Set myDb = Nothing
App.Quit acQuitSaveNone
Set App = Nothing
Exit For
Else
OpenReport = True
Exit For
End If
End If
Next obj
End With

Thank you,
John Bickmore
www.BicycleCam.com
www.Feed-Zone.com



Nov 12 '05 #4
Using the above code in this thread, this means this breaks:

'make the column headers
Set ctlLabel = RPT![lblColumnHeader]
For i = 1 To intColumnCount

with an error of:

438 - object doesn't support this property or method
This works ( automating the report in the same Program MDB ), but automating
the report in the program MDB eventually causes the program MDB to become
corrupt.

'On Error Resume Next
''for now, just do it in the program MDB
'DoCmd.DeleteObject acReport, "MyReportCopy"
'DoCmd.CopyObject "", "MyReportCOPY", acReport, "MyReport"
'DoCmd.OpenReport "MyReportCOPY", acViewDesign
'Set RPT = Reports![MyReportCOPY]
'OpenReport = True
John Bickmore
www.BicycleCam.com
www.Feed-Zone.com
"Danny J. Lesandrini" <dl*********@hotmail.com> wrote in message
news:br***********@ID-82595.news.uni-berlin.de...
I haven't used this process with Access XP, but in Access 97 you
could use a similar method to get the name of a report from the
Reports Container, as you have with the AllReports object.

The problem is, you can't set a report object to it, since it isn't
open. All you have is a name. Add this line ...

DoCmd.OpenReport "[report name]",acViewDesign,,,acHidden

Once it's opened, then the next line, where you set a report object
to it, will work.
--

Danny J. Lesandrini
dl*********@hotmail.com
http://amazecreations.com
"xzzy" <mr********@comcast.net> wrote in message

news:6jJBb.356152$275.1163344@attbi_s53...
I need to automate a report in a different database (and thank yous to Terry Kreft for pointing me in the right direction).

below is the code with the one line that does not work, marked: 'Does not Work'

It appears that the type of object returned from the "AllReports" collection is not a report object.
=>> I need it to be an object of type report.
'for automating remote report
Dim App As Access.Application
Dim myDb As Database
Dim dbs As Object
Dim RPT_Copy As Access.Report
Dim strDBPath As String
Dim obj As Object
Const REPORT_NAME_Copy = "MyReport"

strDBPath = Application.CurrentProject.Path & "\MyData.mdb"
Set App = New Access.Application

With App
.OpenCurrentDatabase strDBPath, False
Set myDb = .CurrentDb
Set dbs = App.CurrentProject
For Each obj In dbs.AllReports
If obj.Name = REPORT_NAME_Copy Then

'Does not Work - the objects are different types
Set RPT = dbs.AllReports(REPORT_NAME_Copy)
'end of Does not Work

If RPT Is Nothing Then
OpenReport = False
On Error Resume Next
myDb.Close
Set myDb = Nothing
App.Quit acQuitSaveNone
Set App = Nothing
Exit For
Else
OpenReport = True
Exit For
End If
End If
Next obj
End With

Thank you,
John Bickmore
www.BicycleCam.com
www.Feed-Zone.com


Nov 12 '05 #5
Dan,

Thank you for your help, your advice of opening in design mode does enable
this assignment to happen:
Set RPT = dbs.AllReports(REPORT_NAME_Copy)

but the following works when it refers to a report in the local MDB and
breaks if it refers to a report in a different MDB ( I need to automate a
report that is in a different MDB ):
'make the column headers
Set ctlLabel = RPT![lblColumnHeader]
For i = 1 . . . . . . .
breaks with an error of:
438 - object doesn't support this property or method
Use this code to open it locally:

'On Error Resume Next
''for now, just do it in the program MDB
'DoCmd.DeleteObject acReport, "MyReportCopy"
'DoCmd.CopyObject "", "MyReportCOPY", acReport, "MyReport"
'DoCmd.OpenReport "MyReportCOPY", acViewDesign
'Set RPT = Reports![MyReportCOPY]
and all references to the RPT object work
John Bickmore
www.BicycleCam.com
www.Feed-Zone.com
"Danny J. Lesandrini" <dl*********@hotmail.com> wrote in message
news:br***********@ID-82595.news.uni-berlin.de...
Did you understand my answer? Is your problem solved already?

I agree, the problem is setting the report object, but the reason
it's a problemis because there is nothing to set it to. Your report
class doesn't exist, until you open the report, so you can't set the
report object equal to it without an error.

Did you try my suggestion, or are you dismissing it out of hand
because it seems incorrect to you?
--
Danny J. Lesandrini
dl*********@hotmail.com
http://amazecreations.com
"xzzy" <mr********@comcast.net> wrote ...
thanks, but setting the report object is the problem

John Bickmore
www.BicycleCam.com
www.Feed-Zone.com

"Danny J. Lesandrini" <dl*********@hotmail.com> wrote in message
news:br***********@ID-82595.news.uni-berlin.de...
I haven't used this process with Access XP, but in Access 97 you
could use a similar method to get the name of a report from the
Reports Container, as you have with the AllReports object.

The problem is, you can't set a report object to it, since it isn't
open. All you have is a name. Add this line ...

DoCmd.OpenReport "[report name]",acViewDesign,,,acHidden

Once it's opened, then the next line, where you set a report object
to it, will work.
--

Danny J. Lesandrini
dl*********@hotmail.com
http://amazecreations.com
"xzzy" <mr********@comcast.net> wrote in message

news:6jJBb.356152$275.1163344@attbi_s53...
> I need to automate a report in a different database (and thank yous
to Terry
> Kreft for pointing me in the right direction).
>
> below is the code with the one line that does not work, marked:
'Does not
> Work'
>
> It appears that the type of object returned from the "AllReports"

collection
> is not a report object.
> =>> I need it to be an object of type report.
>
>
> 'for automating remote report
> Dim App As Access.Application
> Dim myDb As Database
> Dim dbs As Object
> Dim RPT_Copy As Access.Report
> Dim strDBPath As String
> Dim obj As Object
> Const REPORT_NAME_Copy = "MyReport"
>
> strDBPath = Application.CurrentProject.Path & "\MyData.mdb"
> Set App = New Access.Application
>
> With App
> .OpenCurrentDatabase strDBPath, False
> Set myDb = .CurrentDb
> Set dbs = App.CurrentProject
> For Each obj In dbs.AllReports
> If obj.Name = REPORT_NAME_Copy Then
>
> 'Does not Work - the objects are different types
> Set RPT = dbs.AllReports(REPORT_NAME_Copy)
> 'end of Does not Work
>
> If RPT Is Nothing Then
> OpenReport = False
> On Error Resume Next
> myDb.Close
> Set myDb = Nothing
> App.Quit acQuitSaveNone
> Set App = Nothing
> Exit For
> Else
> OpenReport = True
> Exit For
> End If
> End If
> Next obj
> End With
>
>
>
> Thank you,
> John Bickmore
> www.BicycleCam.com
> www.Feed-Zone.com
>
>



Nov 12 '05 #6
Here is part of the solution you're looking for. You created a new App object
and you want to use its methods to manipulate its objects

strDBPath = Application.CurrentProject.Path & "\MyData.mdb"
Set App = New Access.Application

App.OpenCurrentDatabase strDBPath, False

App.DoCmd.OpenReport "rptRequests", acViewDesign, , , acHidden
Set rpt = App.Reports("rptRequests")

rpt.Caption = "New Report Caption Here"
App.DoCmd.Close acReport, "rptRequests", acSaveYes

--
Danny J. Lesandrini
dl*********@hotmail.com
http://amazecreations.com
"xzzy" <mr********@comcast.net> wrote in message news:udLBb.493312$HS4.3783991@attbi_s01...
Using the above code in this thread, this means this breaks:

'make the column headers
Set ctlLabel = RPT![lblColumnHeader]
For i = 1 To intColumnCount

with an error of:

438 - object doesn't support this property or method
This works ( automating the report in the same Program MDB ), but automating
the report in the program MDB eventually causes the program MDB to become
corrupt.

'On Error Resume Next
''for now, just do it in the program MDB
'DoCmd.DeleteObject acReport, "MyReportCopy"
'DoCmd.CopyObject "", "MyReportCOPY", acReport, "MyReport"
'DoCmd.OpenReport "MyReportCOPY", acViewDesign
'Set RPT = Reports![MyReportCOPY]
'OpenReport = True
John Bickmore
www.BicycleCam.com
www.Feed-Zone.com
"Danny J. Lesandrini" <dl*********@hotmail.com> wrote in message
news:br***********@ID-82595.news.uni-berlin.de...
I haven't used this process with Access XP, but in Access 97 you
could use a similar method to get the name of a report from the
Reports Container, as you have with the AllReports object.

The problem is, you can't set a report object to it, since it isn't
open. All you have is a name. Add this line ...

DoCmd.OpenReport "[report name]",acViewDesign,,,acHidden

Once it's opened, then the next line, where you set a report object
to it, will work.
--

Danny J. Lesandrini
dl*********@hotmail.com
http://amazecreations.com
"xzzy" <mr********@comcast.net> wrote in message

news:6jJBb.356152$275.1163344@attbi_s53...
I need to automate a report in a different database (and thank yous to Terry Kreft for pointing me in the right direction).

below is the code with the one line that does not work, marked: 'Does not Work'

It appears that the type of object returned from the "AllReports" collection is not a report object.
=>> I need it to be an object of type report.
'for automating remote report
Dim App As Access.Application
Dim myDb As Database
Dim dbs As Object
Dim RPT_Copy As Access.Report
Dim strDBPath As String
Dim obj As Object
Const REPORT_NAME_Copy = "MyReport"

strDBPath = Application.CurrentProject.Path & "\MyData.mdb"
Set App = New Access.Application

With App
.OpenCurrentDatabase strDBPath, False
Set myDb = .CurrentDb
Set dbs = App.CurrentProject
For Each obj In dbs.AllReports
If obj.Name = REPORT_NAME_Copy Then

'Does not Work - the objects are different types
Set RPT = dbs.AllReports(REPORT_NAME_Copy)
'end of Does not Work

If RPT Is Nothing Then
OpenReport = False
On Error Resume Next
myDb.Close
Set myDb = Nothing
App.Quit acQuitSaveNone
Set App = Nothing
Exit For
Else
OpenReport = True
Exit For
End If
End If
Next obj
End With

Thank you,
John Bickmore
www.BicycleCam.com
www.Feed-Zone.com



Nov 12 '05 #7
Danny,

Thank you for your help

John Bickmore
www.BicycleCam.com
www.Feed-Zone.com
Nov 12 '05 #8

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

Similar topics

7
12835
by: Limey Drink | last post by:
Hi all, Firstly :-) , is there any where I can search through archived newsgroup posts so I am not cluttering up the newsgroup with repeated queries ? And secondly :-), I know this has...
1
2032
by: EnriqueM | last post by:
One question: I created an access database that has been extremely useful in my work. I dont' even know at what level of knowledge I am at. I read a lot about how to create a database, created many...
0
1097
by: Randyb | last post by:
I have an Office XP Access Database with a report "Weekly TimeSheet" in it. I am trying to print out the report from vb.net(2003) without having the users to run access and print the report...
4
3214
by: Supa Hoopsa | last post by:
I am in the process of rewriting an MS Access application (access front end with SQL 2k database) in VB.NET and one of the things I would like to do is link in to the compiled Access ADE so that I...
6
1297
by: Edgar | last post by:
Hi, I need some advise on how to automate record selection on a stored proc. Here is my situation. I have a stored proc that I used on Crystal reports with two parameters - Acctcode and...
2
1342
by: Dave | last post by:
I have to download files every day from a web based application and it's getting very repetitious. I would like to find a way to automate the task. What I have to do each day is go to a website...
2
2610
by: nandishp | last post by:
We need to automate download of Reports from Oracle CRM OnDemand. The reports in Siebel CRM OnDemand can be downloaded in the form of Excel, CSV, etc. We have a task of downloading several such...
0
1270
by: totomalas | last post by:
I have developed a report in Access 2007 that runs on three queries, each promting an input from the user...this report is used for a meeting and it should be printed nine times...what I do now is...
5
2878
by: totomalas | last post by:
I have developed a report in Access 2007 that runs on three queries, each promting an input from the user...this report is used for a meeting and it should be printed nine times...what I do now is...
0
7212
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
7098
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
7296
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
7364
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...
0
5604
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,...
1
5026
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
4696
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...
0
3174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
751
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.