Solved

Delete Control from Report with VBA

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

810 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