Solved

Delete Control from Report with VBA

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now