insert header to report automatically

  • Thread starter Thread starter -003KobeBrian
  • Start date Start date
0

-003KobeBrian

Is there a way to write a code to insert the same subreport to many
different reports automatically? 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
 
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.
 
CurrentProject.AllReports is a collection of report objects. You can spin
through it and get the names of all the reports.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
Back
Top