Connecting Tech Pros Worldwide Forums | Help | Site Map

print preview problem

Michael Turner
Guest
 
Posts: n/a
#1: Nov 12 '05
Hi

Can anyone tell me why I get this error message "Object doesn't support this
property or method."
at the line "Set rpt = Reports!shipping".

The funny thing, is that the same code works fine when placed behind a
button
on some forms but not others.


Dim rpt As Access.Report

DoCmd.OpenReport "shipping", acViewDesign
Set rpt = Reports!shipping
rpt.RecordSource = "qry_shippingCourier"

DoCmd.OpenReport "shipping", acPreview


Thanks in advance

Mick



Rick Brandt
Guest
 
Posts: n/a
#2: Nov 12 '05

re: print preview problem


"Michael Turner" <turner@impedimed.com> wrote in message
news:T0OBb.47839$aT.6814@news-server.bigpond.net.au...[color=blue]
> Hi
>
> Can anyone tell me why I get this error message "Object doesn't support this
> property or method."
> at the line "Set rpt = Reports!shipping".
>
> The funny thing, is that the same code works fine when placed behind a
> button
> on some forms but not others.
>
>
> Dim rpt As Access.Report
>
> DoCmd.OpenReport "shipping", acViewDesign
> Set rpt = Reports!shipping
> rpt.RecordSource = "qry_shippingCourier"
>
> DoCmd.OpenReport "shipping", acPreview[/color]

I don't know why you get the error, but thought I would point out that you can
set the RecordSource property of a Report in its own Open event and eliminate
the need to open it in design view.


--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com


Danny J. Lesandrini
Guest
 
Posts: n/a
#3: Nov 12 '05

re: print preview problem


Let me ask the question ... Why do you want to change recordsource?

Now the answer: If you want to conditionally set the recordsource,
then set it in the Report_Open event. Pass the name of the query in
via the OpenArgs parameter of the DoCmd.OpenReport method.

If you're in Access 97 where there is no OpenArgs for Reports, then
create a public Property Get, Property Let pair (or just a public variable)
to store the value before opening the report, and then retrieve it from
the open event of the report.

This thing about opening an object in design view is whacked. It won't
work in an MDE at all and in an MDB it will create bloat.
--

Danny J. Lesandrini
dlesandrini@hotmail.com
http://amazecreations.com


"Michael Turner" <turner@impedimed.com> wrote ...[color=blue]
> Hi
>
> Can anyone tell me why I get this error message "Object doesn't support this
> property or method."
> at the line "Set rpt = Reports!shipping".
>
> The funny thing, is that the same code works fine when placed behind a
> button
> on some forms but not others.
>
>
> Dim rpt As Access.Report
>
> DoCmd.OpenReport "shipping", acViewDesign
> Set rpt = Reports!shipping
> rpt.RecordSource = "qry_shippingCourier"
>
> DoCmd.OpenReport "shipping", acPreview
>
>
> Thanks in advance
>
> Mick
>
>[/color]


Closed Thread