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 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
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
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
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
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 > >
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
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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...
|
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...
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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,...
|
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...
| |
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,...
|
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...
|
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,...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |