Solved

Delete Control from Report with VBA

Posted on 2004-08-27
5
805 Views
Last Modified: 2008-03-06
Is there any way to delete controls from a report programmatically with VBA?  I'm building a dynamic report that creates new textboxes, but I want to make sure that I clean up and delete previous iterations before adding the new textboxes.  I'm aware of the apparently undocumented "DeleteControl" method for forms.  Is there something similar for reports?
0
Comment
Question by:murdochah
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 125 total points
ID: 11918351
The DeleteReportControl method is what you are after:

DoCmd.OpenReport "MyReport",acViewDesign
DeleteReportControl "MyReport","MyControl"
DoCmd.Close acReport,"MyReport",acSaveYes
0
 
LVL 39

Expert Comment

by:stevbe
ID: 11920533
If you just change the .Visible property then you don't have to open in design and save. I run into this kind of thing because I deploy to a runtime environment only.

Steve
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 11921085
True, but I think murdochah is doing this to clean up a report design rather than dynamically altering the report on the fly. I'm not sure what his circumstances are though.
0
 

Author Comment

by:murdochah
ID: 11935626
I got it to work properly, my only question is this:  does the DeleteReportControl method show up in your copy of the Access Help documentation?  I couldn't find it in the help so I'm wondering if it's undocumented, or if my Access Help documentation has gotten corrupted somehow.  

Thanks for the help!
Andrew
0
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 11935700
It's in my help doc - I'm using Access 2002.
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question