Terry,
Thank you for your very helpful sample code.
John Bickmore
www.BicycleCam.com www.Feed-Zone.com
"Terry Kreft" <terry.kreft@mps.co.uk> wrote in message
news:bqi4n5$qdm$1@newsreaderg1.core.theplanet.net. ..[color=blue]
>
> Because the name property is a string type and your Rpt variable is of[/color]
type[color=blue]
> 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" <mrbikejoc1@comcast.net> wrote in message
> news:RT%yb.394135$Tr4.1148717@attbi_s03...[color=green]
> > Thank you, however using:
> >
> > Set rpt = MyDB.Containers(5).Documents(0).Name
> >
> > returns "Type Mis-match"
> >
> >
> > "DFS" <nospamDS@nospam.com> wrote in message
> > news:vsoduvghfgfub2@corp.supernews.com...[color=darkred]
> > > Try leaving off the Properties(0).Name:
> > >
> > > Set rpt = MyDB.Containers(5).Documents(i)
> > >
> > >
> > >
> > >
> > > "xzzy" <mrbikejoc1@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"[/color][/color][/color]
Then[color=blue][color=green][color=darkred]
> > > >
> > > >
> > > >
> > > > 'the following line works
> > > > DoCmd.OpenReport[/color][/color][/color]
MyDB.Containers(5).Documents(i).Name,[color=blue][color=green][color=darkred]
> > > > acViewDesign
> > > >
> > > > 'I need to set the object RPT to the remote report that is now in[/color][/color]
> design[color=green][color=darkred]
> > > > 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
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]