HOWTO: Edit Report Code Programmatically

D

Dan Johnson

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
 
M

Marshall Barton

Dan said:
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.
 
D

Dan Johnson

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
 
M

Marshall Barton

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.
 

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