473,387 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

automate report in different mdb

I need to automate a report in a different database.

Dim RPT as Report

Set MyDB = wrkJet.OpenDatabase(Application.CurrentProject.Pat h &
"\Mydb.mdb", True, False)

For i = 0 To MyDB.Containers(5).Documents.Count - 1
If MyDB.Containers(5).Documents(i).Name = "MyReport" Then

'the following line works
DoCmd.OpenReport MyDB.Containers(5).Documents(i).Name,
acViewDesign

'I need to set the object RPT to the remote report that is now in design
mode.
'The following line of code does not work:
Set rpt = MyDB.Containers(5).Documents(i).Properties(0).Name

End If
Next i

Thank you for your help
Nov 12 '05 #1
6 1522
DFS
Try leaving off the Properties(0).Name:

Set rpt = MyDB.Containers(5).Documents(i)


"xzzy" <mr********@comcast.net> wrote in message
news:eAWyb.277096$9E1.1459853@attbi_s52...
I need to automate a report in a different database.

Dim RPT as Report

Set MyDB = wrkJet.OpenDatabase(Application.CurrentProject.Pat h &
"\Mydb.mdb", True, False)

For i = 0 To MyDB.Containers(5).Documents.Count - 1
If MyDB.Containers(5).Documents(i).Name = "MyReport" Then

'the following line works
DoCmd.OpenReport MyDB.Containers(5).Documents(i).Name,
acViewDesign

'I need to set the object RPT to the remote report that is now in design
mode.
'The following line of code does not work:
Set rpt = MyDB.Containers(5).Documents(i).Properties(0).Name
End If
Next i

Thank you for your help

Nov 12 '05 #2
Thank you, however using:

Set rpt = MyDB.Containers(5).Documents(0).Name

returns "Type Mis-match"
"DFS" <no******@nospam.com> wrote in message
news:vs************@corp.supernews.com...
Try leaving off the Properties(0).Name:

Set rpt = MyDB.Containers(5).Documents(i)


"xzzy" <mr********@comcast.net> wrote in message
news:eAWyb.277096$9E1.1459853@attbi_s52...
I need to automate a report in a different database.

Dim RPT as Report

Set MyDB = wrkJet.OpenDatabase(Application.CurrentProject.Pat h &
"\Mydb.mdb", True, False)

For i = 0 To MyDB.Containers(5).Documents.Count - 1
If MyDB.Containers(5).Documents(i).Name = "MyReport" Then

'the following line works
DoCmd.OpenReport MyDB.Containers(5).Documents(i).Name,
acViewDesign

'I need to set the object RPT to the remote report that is now in design
mode.
'The following line of code does not work:
Set rpt =

MyDB.Containers(5).Documents(i).Properties(0).Name

End If
Next i

Thank you for your help


Nov 12 '05 #3

Because the name property is a string type and your Rpt variable is of type
Report.

The method you are trying to use is wrong, have a look at something like

Dim App As Access.Application
Dim myDb As DAO.Database
Dim strDBPath As String
Dim RPT As Access.Report
Dim blnFound As Boolean

Const REPORT_NAME = "MyReport"

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

With App
.OpenCurrentDatabase strDBPath, True
Set myDb = .CurrentDb
End With

For i = 0 To myDb.Containers(5).Documents.Count - 1
If myDb.Containers(5).Documents(i).Name = REPORT_NAME Then
App.DoCmd.OpenReport REPORT_NAME, acViewDesign
Set RPT = App.Reports(REPORT_NAME)
blnFound = True
Else
blnFound = False
End If
Next i

If blnFound Then
' Do whatever you want with the report
End If

App.DoCmd.Close acReport, REPORT_NAME, acSaveYes
Set RPT = Nothing
App.Quit acQuitSaveAll
Set myDb = Nothing
Set App = Nothing

Terry
"xzzy" <mr********@comcast.net> wrote in message
news:RT%yb.394135$Tr4.1148717@attbi_s03...
Thank you, however using:

Set rpt = MyDB.Containers(5).Documents(0).Name

returns "Type Mis-match"
"DFS" <no******@nospam.com> wrote in message
news:vs************@corp.supernews.com...
Try leaving off the Properties(0).Name:

Set rpt = MyDB.Containers(5).Documents(i)


"xzzy" <mr********@comcast.net> wrote in message
news:eAWyb.277096$9E1.1459853@attbi_s52...
I need to automate a report in a different database.

Dim RPT as Report

Set MyDB = wrkJet.OpenDatabase(Application.CurrentProject.Pat h &
"\Mydb.mdb", True, False)

For i = 0 To MyDB.Containers(5).Documents.Count - 1
If MyDB.Containers(5).Documents(i).Name = "MyReport" Then

'the following line works
DoCmd.OpenReport MyDB.Containers(5).Documents(i).Name,
acViewDesign

'I need to set the object RPT to the remote report that is now in design mode.
'The following line of code does not work:
Set rpt =

MyDB.Containers(5).Documents(i).Properties(0).Name

End If
Next i

Thank you for your help



Nov 12 '05 #4
DFS
xzzy,

It looks like "Terry" gave you a good answer, but it seems you didn't try my
suggestion correctly.

I said to try "Set rpt = MyDB.Containers(5).Documents(i)"

and you said you tried "Set rpt = MyDB.Containers(5).Documents(0).Name" and
it threw an error.


"xzzy" <mr********@comcast.net> wrote in message
news:RT%yb.394135$Tr4.1148717@attbi_s03...
Thank you, however using:

Set rpt = MyDB.Containers(5).Documents(0).Name

returns "Type Mis-match"
"DFS" <no******@nospam.com> wrote in message
news:vs************@corp.supernews.com...
Try leaving off the Properties(0).Name:

Set rpt = MyDB.Containers(5).Documents(i)


"xzzy" <mr********@comcast.net> wrote in message
news:eAWyb.277096$9E1.1459853@attbi_s52...
I need to automate a report in a different database.

Dim RPT as Report

Set MyDB = wrkJet.OpenDatabase(Application.CurrentProject.Pat h &
"\Mydb.mdb", True, False)

For i = 0 To MyDB.Containers(5).Documents.Count - 1
If MyDB.Containers(5).Documents(i).Name = "MyReport" Then

'the following line works
DoCmd.OpenReport MyDB.Containers(5).Documents(i).Name,
acViewDesign

'I need to set the object RPT to the remote report that is now in design mode.
'The following line of code does not work:
Set rpt =

MyDB.Containers(5).Documents(i).Properties(0).Name

End If
Next i

Thank you for your help



Nov 12 '05 #5
Whoops slight error

For i = 0 To myDb.Containers(5).Documents.Count - 1
If myDb.Containers(5).Documents(i).Name = REPORT_NAME Then
App.DoCmd.OpenReport REPORT_NAME, acViewDesign
Set RPT = App.Reports(REPORT_NAME)
blnFound = True
Else
blnFound = False
End If
Next i

Should be

For i = 0 To myDb.Containers(5).Documents.Count - 1
If myDb.Containers(5).Documents(i).Name = REPORT_NAME Then
App.DoCmd.OpenReport REPORT_NAME, acViewDesign
Set RPT = App.Reports(REPORT_NAME)
blnFound = True
' Missing line follows
Exit For
Else
blnFound = False
End If
Next i

Terry

"Terry Kreft" <te*********@mps.co.uk> wrote in message
news:bq**********@newsreaderg1.core.theplanet.net. ..

Because the name property is a string type and your Rpt variable is of type Report.

The method you are trying to use is wrong, have a look at something like

Dim App As Access.Application
Dim myDb As DAO.Database
Dim strDBPath As String
Dim RPT As Access.Report
Dim blnFound As Boolean

Const REPORT_NAME = "MyReport"

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

With App
.OpenCurrentDatabase strDBPath, True
Set myDb = .CurrentDb
End With

For i = 0 To myDb.Containers(5).Documents.Count - 1
If myDb.Containers(5).Documents(i).Name = REPORT_NAME Then
App.DoCmd.OpenReport REPORT_NAME, acViewDesign
Set RPT = App.Reports(REPORT_NAME)
blnFound = True
Else
blnFound = False
End If
Next i

If blnFound Then
' Do whatever you want with the report
End If

App.DoCmd.Close acReport, REPORT_NAME, acSaveYes
Set RPT = Nothing
App.Quit acQuitSaveAll
Set myDb = Nothing
Set App = Nothing

Terry
"xzzy" <mr********@comcast.net> wrote in message
news:RT%yb.394135$Tr4.1148717@attbi_s03...
Thank you, however using:

Set rpt = MyDB.Containers(5).Documents(0).Name

returns "Type Mis-match"
"DFS" <no******@nospam.com> wrote in message
news:vs************@corp.supernews.com...
Try leaving off the Properties(0).Name:

Set rpt = MyDB.Containers(5).Documents(i)


"xzzy" <mr********@comcast.net> wrote in message
news:eAWyb.277096$9E1.1459853@attbi_s52...
> I need to automate a report in a different database.
>
> Dim RPT as Report
>
> Set MyDB = wrkJet.OpenDatabase(Application.CurrentProject.Pat h &
> "\Mydb.mdb", True, False)
>
> For i = 0 To MyDB.Containers(5).Documents.Count - 1
> If MyDB.Containers(5).Documents(i).Name = "MyReport" Then >
>
>
> 'the following line works
> DoCmd.OpenReport MyDB.Containers(5).Documents(i).Name, > acViewDesign
>
> 'I need to set the object RPT to the remote report that is now in design > mode.
> 'The following line of code does not work:
> Set rpt =
MyDB.Containers(5).Documents(i).Properties(0).Name
>
>
>
> End If
> Next i
>
>
>
> Thank you for your help
>
>



Nov 12 '05 #6
Terry,

Thank you for your very helpful sample code.

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

"Terry Kreft" <te*********@mps.co.uk> wrote in message
news:bq**********@newsreaderg1.core.theplanet.net. ..

Because the name property is a string type and your Rpt variable is of type Report.

The method you are trying to use is wrong, have a look at something like

Dim App As Access.Application
Dim myDb As DAO.Database
Dim strDBPath As String
Dim RPT As Access.Report
Dim blnFound As Boolean

Const REPORT_NAME = "MyReport"

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

With App
.OpenCurrentDatabase strDBPath, True
Set myDb = .CurrentDb
End With

For i = 0 To myDb.Containers(5).Documents.Count - 1
If myDb.Containers(5).Documents(i).Name = REPORT_NAME Then
App.DoCmd.OpenReport REPORT_NAME, acViewDesign
Set RPT = App.Reports(REPORT_NAME)
blnFound = True
Else
blnFound = False
End If
Next i

If blnFound Then
' Do whatever you want with the report
End If

App.DoCmd.Close acReport, REPORT_NAME, acSaveYes
Set RPT = Nothing
App.Quit acQuitSaveAll
Set myDb = Nothing
Set App = Nothing

Terry
"xzzy" <mr********@comcast.net> wrote in message
news:RT%yb.394135$Tr4.1148717@attbi_s03...
Thank you, however using:

Set rpt = MyDB.Containers(5).Documents(0).Name

returns "Type Mis-match"
"DFS" <no******@nospam.com> wrote in message
news:vs************@corp.supernews.com...
Try leaving off the Properties(0).Name:

Set rpt = MyDB.Containers(5).Documents(i)


"xzzy" <mr********@comcast.net> wrote in message
news:eAWyb.277096$9E1.1459853@attbi_s52...
> I need to automate a report in a different database.
>
> Dim RPT as Report
>
> Set MyDB = wrkJet.OpenDatabase(Application.CurrentProject.Pat h &
> "\Mydb.mdb", True, False)
>
> For i = 0 To MyDB.Containers(5).Documents.Count - 1
> If MyDB.Containers(5).Documents(i).Name = "MyReport" Then >
>
>
> 'the following line works
> DoCmd.OpenReport MyDB.Containers(5).Documents(i).Name, > acViewDesign
>
> 'I need to set the object RPT to the remote report that is now in design > mode.
> 'The following line of code does not work:
> Set rpt =
MyDB.Containers(5).Documents(i).Properties(0).Name
>
>
>
> End If
> Next i
>
>
>
> Thank you for your help
>
>



Nov 12 '05 #7

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

Similar topics

6
by: John Galt | last post by:
Does anyone have working code to send a fax from VBA using Outlook.Mailitem? I have tried some examples I have found and they all simply try to use the Fax number as an e-mail address. Thanks in...
3
by: CSDunn | last post by:
Hello, I have a situation with MS Access 2000 in which I need to display report data in spreadsheet orientation (much like a datasheet view for a form). If you think of the report in terms of what...
16
by: cyranoVR | last post by:
This is the approach I used to automate printing of Microsoft Access reports to PDF format i.e. unattended and without annoying "Save As..." dialogs, and - more importantly - without having to use...
2
by: Phil Latio | last post by:
We have despatch process which kicks out picking information into text files at hourly intervals. The text files are named sequentially by process; 'ABC.txt', 'ABC01.txt', 'ABC02.txt' for one...
25
by: MLH | last post by:
In an earlier post entitled... "A97 closes down each time I open a particular report" it has been suggested that I rebuild problematic table - one in which some corruption has occurred. I...
2
by: sanditaylor | last post by:
Hi There, I'm quite new to access & to VB. I'm working with a database which through a form, you can generate a pdf report (using pdf995). Choose the report from a dropdown box, and then click...
2
by: teddarr | last post by:
My company maintains an access database. We use this database to generate a report 3 times a day and email it to a distribution list. How do I go about using the system clock to automate the report...
1
by: Ronald S. Cook | last post by:
We have a Win app that we publish via built-in ClickOnce. However, we have 10 different locations to which we deploy the app. Each time we have a new build to publish, we have to change the IP in...
1
by: audrey.nsh | last post by:
Hi, I have an Access 97 database where the users loads the data (from multiple sources) and generates forms (that looks like reports) at a click of the button and the user saves the form as .xls...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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,...

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.