A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

HOWTO: Edit Report Code Programmatically



 
 
Thread Tools Display Modes
  #1  
Old December 5th, 2006, 07:25 PM posted to microsoft.public.access.reports
Dan Johnson
external usenet poster
 
Posts: 11
Default HOWTO: Edit Report Code Programmatically

Our VB6 app makes use of an Access database report object that contains a
small amount of code. We are currently preparing an update exe for this app
where one of the updates is a change to the code in the Access report.
Since the user may have changed the design of the report, we do not want to
overwrite the existing Access database when installing the update.

Can anyone point me in the right direction for editing the code of an Access
report using the Access object model? What I would like to do is access the
report's code, then just overwrite all of the code with a stored string.
Hopefully that makes sense...

Thanks for any help!

Dan


  #2  
Old December 5th, 2006, 10:42 PM posted to microsoft.public.access.reports
Marshall Barton
external usenet poster
 
Posts: 5,361
Default HOWTO: Edit Report Code Programmatically

Dan Johnson wrote:

Our VB6 app makes use of an Access database report object that contains a
small amount of code. We are currently preparing an update exe for this app
where one of the updates is a change to the code in the Access report.
Since the user may have changed the design of the report, we do not want to
overwrite the existing Access database when installing the update.

Can anyone point me in the right direction for editing the code of an Access
report using the Access object model? What I would like to do is access the
report's code, then just overwrite all of the code with a stored string.
Hopefully that makes sense...



I think you need to use Automation to open the mdb file.
Then you can Open the report in design view using DoCmd
OpenForm. The report object's Module property's DeleteLines
and InsertLines methods can be used to di what you want.
Check VBA Help for the Module Object for details.

--
Marsh
MVP [MS Access]
  #3  
Old December 7th, 2006, 05:10 PM posted to microsoft.public.access.reports
Dan Johnson
external usenet poster
 
Posts: 11
Default HOWTO: Edit Report Code Programmatically

Thanks Marshall.

Do you have to add the Event Procedures separately using the CreateEventProc
method (and then add the applicable lines to the procedure), or can I just
create one string variable, containing text for both the event procedures
headings and the related code lines within the procedure? Looks like I need
to create the procedure, then add the lines to the procedure.

Dan


"Marshall Barton" wrote in message
...
Dan Johnson wrote:

Our VB6 app makes use of an Access database report object that contains a
small amount of code. We are currently preparing an update exe for this

app
where one of the updates is a change to the code in the Access report.
Since the user may have changed the design of the report, we do not want

to
overwrite the existing Access database when installing the update.

Can anyone point me in the right direction for editing the code of an

Access
report using the Access object model? What I would like to do is access

the
report's code, then just overwrite all of the code with a stored string.
Hopefully that makes sense...



I think you need to use Automation to open the mdb file.
Then you can Open the report in design view using DoCmd
OpenForm. The report object's Module property's DeleteLines
and InsertLines methods can be used to di what you want.
Check VBA Help for the Module Object for details.

--
Marsh
MVP [MS Access]



  #4  
Old December 7th, 2006, 06:09 PM posted to microsoft.public.access.reports
Marshall Barton
external usenet poster
 
Posts: 5,361
Default HOWTO: Edit Report Code Programmatically

It's been awhile, but I think you can do the whole thing in
one shot. Try it on a test report and see what happens.
--
Marsh
MVP [MS Access]


Dan Johnson wrote:
Do you have to add the Event Procedures separately using the CreateEventProc
method (and then add the applicable lines to the procedure), or can I just
create one string variable, containing text for both the event procedures
headings and the related code lines within the procedure? Looks like I need
to create the procedure, then add the lines to the procedure.


"Marshall Barton" wrote
Dan Johnson wrote:

Our VB6 app makes use of an Access database report object that contains a
small amount of code. We are currently preparing an update exe for this

app
where one of the updates is a change to the code in the Access report.
Since the user may have changed the design of the report, we do not want

to
overwrite the existing Access database when installing the update.

Can anyone point me in the right direction for editing the code of an

Access
report using the Access object model? What I would like to do is access

the
report's code, then just overwrite all of the code with a stored string.
Hopefully that makes sense...



I think you need to use Automation to open the mdb file.
Then you can Open the report in design view using DoCmd
OpenForm. The report object's Module property's DeleteLines
and InsertLines methods can be used to di what you want.
Check VBA Help for the Module Object for details.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:22 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.