insert header to report automatically

0

-003KobeBrian

Is there a way to write a code to insert the same subreport to many
different reports automatically? Thanks.
 
A

Alex Dybenko

Hi,
Do not see any problem with this - you have to open each report in design
mode using docmd.openreport, then add new control using CreateControl, and
then format it as required.
The tricky part if you have other controls on the section where you insert
subreport - then you have to move existing control around it

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com
 
0

-003KobeBrian

Thanks again, Alex. If I want to put the code in module and scan all the
reports and insert, do you know how to do it once for all instead of one by
one? Something like where I can get all the report names in the mdb. Thanks.
 
K

Klatuu

CurrentProject.AllReports is a collection of report objects. You can spin
through it and get the names of all the reports.
 
0

-003KobeBrian

I couldn't find the currentproject.allreports in access97. I found the
application.reports. But this is the open report. How do I use all reports
including open and non-open ones? Thanks.
 
0

-003KobeBrian

When I tried to insert a report, I use the following code and I got the
error message "type mismatch". reportheader is the subreport existed. and I
want it to assign to the new report as a subreport.

Set ctl = CreateReportControl(rpt.Name, acSubform, acPageHeader, ,
Reports![reportheader])

And how do you assign name to this command. Please help. Thanks.
 
A

Alex Dybenko

Hi,
not sure that you need to pass Reports![reportheader], try leave it out.
once you get a reference to ctl - you can then set it other properties

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com


-003KobeBrian said:
When I tried to insert a report, I use the following code and I got the
error message "type mismatch". reportheader is the subreport existed. and
I want it to assign to the new report as a subreport.

Set ctl = CreateReportControl(rpt.Name, acSubform, acPageHeader, ,
Reports![reportheader])

And how do you assign name to this command. Please help. Thanks.



Klatuu said:
CurrentProject.AllReports is a collection of report objects. You can
spin
through it and get the names of all the reports.
 
0

-003KobeBrian

How do you pass the source control to ctl? What is the syntax? THanks.


Alex Dybenko said:
Hi,
not sure that you need to pass Reports![reportheader], try leave it out.
once you get a reference to ctl - you can then set it other properties

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com


-003KobeBrian said:
When I tried to insert a report, I use the following code and I got the
error message "type mismatch". reportheader is the subreport existed.
and I want it to assign to the new report as a subreport.

Set ctl = CreateReportControl(rpt.Name, acSubform, acPageHeader, ,
Reports![reportheader])

And how do you assign name to this command. Please help. Thanks.



Klatuu said:
CurrentProject.AllReports is a collection of report objects. You can
spin
through it and get the names of all the reports.

:

Thanks again, Alex. If I want to put the code in module and scan all
the
reports and insert, do you know how to do it once for all instead of
one by
one? Something like where I can get all the report names in the mdb.
Thanks.

Hi,
Do not see any problem with this - you have to open each report in
design
mode using docmd.openreport, then add new control using
CreateControl, and
then format it as required.
The tricky part if you have other controls on the section where you
insert
subreport - then you have to move existing control around it

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

Is there a way to write a code to insert the same subreport to many
different reports automatically? Thanks.
 
A

Alex Dybenko

I think using SourceObject

ctl.SourceObject="Mysubform"

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

-003KobeBrian said:
How do you pass the source control to ctl? What is the syntax? THanks.


Alex Dybenko said:
Hi,
not sure that you need to pass Reports![reportheader], try leave it out.
once you get a reference to ctl - you can then set it other properties

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com


-003KobeBrian said:
When I tried to insert a report, I use the following code and I got the
error message "type mismatch". reportheader is the subreport existed.
and I want it to assign to the new report as a subreport.

Set ctl = CreateReportControl(rpt.Name, acSubform, acPageHeader, ,
Reports![reportheader])

And how do you assign name to this command. Please help. Thanks.



CurrentProject.AllReports is a collection of report objects. You can
spin
through it and get the names of all the reports.

:

Thanks again, Alex. If I want to put the code in module and scan all
the
reports and insert, do you know how to do it once for all instead of
one by
one? Something like where I can get all the report names in the mdb.
Thanks.

Hi,
Do not see any problem with this - you have to open each report in
design
mode using docmd.openreport, then add new control using
CreateControl, and
then format it as required.
The tricky part if you have other controls on the section where you
insert
subreport - then you have to move existing control around it

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

Is there a way to write a code to insert the same subreport to many
different reports automatically? Thanks.
 
G

George Nicholson

The CopyObject method mimics the manual process of selecting a db object &
doing a copy/paste.

Aircode adapted from a couple of Help entries:

Dim obj As AccessObject
Dim dbs As Object
Set dbs = Application.CurrentProject

For Each obj In dbs.AllReports
DoCmd.CopyObject, "Copy of " obj.Name, acReport, obj.Name
Next obj

This assumes you are using Access 2000(?) or higher. Fairly certain that's
when CurrentProject, AllReports and AccessObject were introduced to the
Access object model.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top