Solved

Delete Control from Report with VBA

Posted on 2004-08-27
5
768 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
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…

696 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