ACC: DeleteControl, DeleteReportControl, and CreateGroupLevel (93094)
The information in this article applies to:
- Microsoft Access 1.0
- Microsoft Access 1.1
- Microsoft Access 2.0
- Microsoft Access for Windows 95 7.0
- Microsoft Access 97
- Microsoft Visual Basic for Applications 1.0
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
"Building Applications with Microsoft Access" 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 "Introduction to Programming" manual in Microsoft
Access version 1.x or the "Building Applications" 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 "About to Delete " & 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 "About to Delete " & 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.
Modification Type: | Minor | Last Reviewed: | 8/15/2005 |
---|
Keywords: | kbinfo kbProgramming KB93094 |
---|
|