Microsoft KB Archive/93094

= ACC: DeleteControl, DeleteReportControl, and CreateGroupLevel =

Article ID: 93094

Article Last Modified on 1/18/2007

-

APPLIES TO


 * Microsoft Access 1.0 Standard Edition
 * Microsoft Access 1.1 Standard Edition
 * Microsoft Access 2.0 Standard Edition
 * Microsoft Access 95 Standard Edition
 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q93094



Moderate: Requires basic macro, coding, and interoperability skills.



SUMMARY
This article discusses the DeleteControl and DeleteReportControl statements and the CreateGroupLevel function. If you intend to write your own form wizard or report wizard, you can use these statements to delete controls on a form or a report that is available in Design view, and you can use the function to create groups on a report that is available in Design view.

This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to your version of the &quot;Building Applications with Microsoft Access&quot; manual.

NOTE: Visual Basic for Applications is called Access Basic in Microsoft Access versions 1.x and 2.0. For more information about Access Basic, please refer to the &quot;Introduction to Programming&quot; manual in Microsoft Access version 1.x or the &quot;Building Applications&quot; manual in Microsoft Access version 2.0.



MORE INFORMATION
You can use DeleteControl and DeleteReportControl statements to delete a control that exists on a form or report in Design view. Both statements require a string value that represents the name of the form or report and a string value that represents the name of the control.

DeleteControl and DeleteReportControl are statements, not functions. They do not return a value.

The following example creates a form, creates a button on the form, displays a message, and then deletes the button on the form. To create the form, follow these steps.

In Microsoft Access 2.0, 7.0, and 97
Dim MyForm As Form, MyControl As Control Set MyForm = CreateForm Set MyControl = CreateControl(MyForm.Name, 104) MsgBox &quot;About to Delete &quot; & MyControl.Name DeleteControl MyForm.Name, MyControl.Name

In Microsoft Access 1.x
Dim MyForm As Form, MyControl As Control Set MyForm = CreateForm Set MyControl = CreateControl(MyForm.FormName, 104) MsgBox &quot;About to Delete &quot; & MyControl.ControlName DeleteControl MyForm.FormName, MyControl.ControlName When you delete a control using DeleteControl or DeleteReportControl, there is no visual feedback that the control is gone if the form or report is not minimized. The control still appears as if it were not deleted even though you cannot click it to give it focus. To make the deleted control disappear, you must repaint the form Design window by minimizing it and then restoring it.

If you have a report available in Design view, you can create groups for it in a procedure by using the CreateGroupLevel function. Here is the syntax for CreateGroupLevel: Function CreateGroupLevel(ReportName$,Expression$,                            HasHeader$, HasFooter$) ReportName is a string expression representing the report name.

Expression is a string expression representing the name of the field or calculated field that you want to group by.

HasHeader and HasFooter indicate whether the group includes a group header or group footer, respectively. The values are True and False.

When it runs, CreateGroupLevel adds a group at the innermost level. For example, if one group already exists, CreateGroupLevel creates a second group within the first group. CreateGroupLevel returns a number that indicates which level it created, beginning with zero. In the example just mentioned, CreateGroupLevel returns 1 because it is the second group, and the first group was Group zero.

Keywords: kbinfo kbprogramming KB93094

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.