INF: Using Undocumented CreateForm(),CreateReport() Functions [B_WACCESS]
ID: Q93096     CREATED: 23-NOV-1992   MODIFIED: 15-DEC-1992
1.00
WINDOWS
ENDUSER |  

----------------------------------------------------------------------
The information in this article applies to:
 
 - Microsoft Access version 1.0
----------------------------------------------------------------------
 
Summary:
 
This article discusses the Microsoft Access undocumented functions
CreateForm() and CreateReport(). If you intend to write your own
FormWizard or ReportWizard, you can use these functions to create and
customize a blank form or report to which you can add controls.
 
This article assumes that you are familiar with Access Basic and
designing forms and reports.
 
More Information:
 
CreateForm()/CreateReport() is roughly equivalent to choosing "New...
Form/New... Report" from the File menu at the top of the screen. When
the function is executed, a new empty form/report appears in an
iconized state.
 
Both functions return an object value that you can use for further
manipulation, and neither function requires parameters.
 
To use these functions, first define a form or report object
variable, then assign the variable to the function name. An example of
how to do this is:
 
   Dim MyForm As Form
   Set MyForm = CreateForm()
 
After opening the form/report in design mode after executing the
commands above, you can bind the form to a table or query by modifying
the form's/report's RecordSource property:
 
   MyForm.RecordSource = "Categories"
 
With the form/report in design mode, you can access and
change any of the other design-time properties of the form/report. You
can also access and change properties of each of the form's/report's
sections via the Section property. The Section property is actually an
array with each array value being a reference to a form's/report's
section. For forms, the Section property array is broken down as:
 
   Section(0) - Detail Section
   Section(1) - Form Header
   Section(2) - Form Footer
   Section(3) - Page Header
   Section(4) - Page Footer
 
For reports, the section property array is broken down as:
 
   Section(0) - Detail Section
   Section(1) - Report Header
   Section(2) - Report Footer
   Section(3) - Page Header
   Section(4) - Page Footer
   Section(5) - Group Level 1 Header
   Section(6) - Group Level 1 Footer
   Section(7) - Group Level 2 Header
      ...etc.
 
With this information, you can customize the design of a form/report
section programmatically. The following example creates a new report,
hides the page footer by setting its Visible property to false, sets
the Height property of the detail section, and enables its
KeepTogether property:
 
   Dim MyReport As Report
   Set MyReport = CreateReport()
   MyReport.Section(4).Visible = False
   MyReport.Section(0).Height = 1760
   MyReport.Section(0).KeepTogether = True

For more information on Microsoft Access libraries, query on the
following words in the Microsoft Knowledge Base:

    "libraries AND debugging AND creating" 
 
For more information about other ReportWizard and FormWizard
functions, query on the following words in the Microsoft Knowledge
Base:

   "CreateControl AND CreateReportControl AND CreateForm AND 
   CreateReport AND 'Section Property' AND DeleteControl AND 
   DeleteReportControl AND CreateGroupLevel"

===========================================================================

INF: Wizards Part II - CreateControl(), CreateReportControl() [B_WACCESS]
ID: Q93095     CREATED: 23-NOV-1992   MODIFIED: 23-NOV-1992
1.00
WINDOWS
ENDUSER |  

 
----------------------------------------------------------------------
The information in this article applies to:
 
 - Microsoft Access version 1.0
----------------------------------------------------------------------
 
Summary:
 
This article discusses the Microsoft Access undocumented functions
CreateControl() and CreateReportControl().  If you intend to write your
own Forms and/or Reports Wizard, you can use these functions to create
controls on a form or report that is available in Design mode.
 
For more understanding of Microsoft Access Libraries, search
on the Knowledge Base for the following keywords:
 
   libraries AND debugging AND creating
 
For more information about other Wizard functions, query the Knowledge Base
for:
 
   CreateControl AND CreateReportControl AND CreateForm AND CreateReport AND
     'Section Property' AND DeleteControl AND DeleteReportControl AND
        CreateGroupLevel
 
This article also assumes you are familiar with Access Basic and with
designing forms and reports.
 
More Information:
 
CreateControl() and CreateReportControl() can be used to create new
controls for a form/report opened in Design mode.  These functions
require the name of the form/report represented as a string value,
and a numeric code that represents the type of control.  The list of
control types and their associated numeric codes are shown below:
 
   Label .......... 100
   Box ............ 101
   Line ........... 102
   Picture ........ 103
   Button ......... 104
   Radio Button ... 105
   Check Box ...... 106
   Ole Object ..... 108
   Text Box ....... 109
 
The CreateControl() and CreateReportControl() functions return a
control object value, so you must first define a control variable,
then Set the variable to the function name.  Note the code example
below which creates a form, then adds a button to the form:
 
   Dim MyForm As Form, MyControl As Control
   Set MyForm = CreateForm()
   Set MyControl = CreateControl(MyForm.FormName, 104)
 
After executing the code example above, you can modify the properies
of the new control via the control variable you defined.  For example:
 
   MyControl.Width = 2000
   MyControl.Caption = "&Sum All Records"
 
For controls that are frequently associated with fields in a table or
query, you can modify the ControlSource property to bind the control.
Some controls are created with Height and Width properties set to 0,
so that they are - in effect - not visible.  In addition, controls
appear at the uppermost left-hand corner of the form by default.
Because of this, you should make it a habit to adjust the size and
position of the control immediately after creating it.  The example
below shows how to create, size, move, and bind a text box.
 
   Set MyControl = CreateControl(MyForm.FormName, 109)
   MyControl.Width = 1500
   MyControl.Height = 200
   MyControl.Top = 440
   MyControl.Left = 200
   MyControl.ControlSource = "[Category ID]"
 
In addition to specifying the form name and type of control, you can
optionally specify the Section in which the control should be created.
Note the syntactical structure of CreateControl(), (which is identical
to the syntactical structure of CreateReportControl()):
 
   Function CreateControl (FormName As String,
                           ControlType As Integer
                           [,SectionNumber As Integer])
 
Use the SectionNumber parameter to indicate what section the control is
to be placed into.  The section that is associated with the

SectionNumber is the same as the index representing a section in a
Section property array.


===========================================================================

INF: Wizards Part III - DeleteControl, DeleteReportControl,   [B_WACCESS]
ID: Q93094     CREATED: 23-NOV-1992   MODIFIED: 23-NOV-1992
1.00
WINDOWS
ENDUSER |  

 
 
Summary:
 
This article discusses the Microsoft Access undocumented commands
DeleteControl, DeleteReportControl, and the undocumented function
CreateGroupLevel().  If you intend to write your own Forms and/or
Reports Wizard, you can use these functions to delete controls on a form
or report that is available in Design mode, and create groups on a
Report that is available in Design mode.
 
For more understanding of Microsoft Access Libraries, search
on the Knowledge Base for the following keywords:
 
   libraries AND debugging AND creating
 
For more information about other Wizard functions, query the Knowledge Base
for:
 
   CreateControl AND CreateReportControl AND CreateForm AND CreateReport AND
     'Section Property' AND DeleteControl AND DeleteReportControl AND
        CreateGroupLevel
 
 
More Information:
 
DeleteControl and DeleteReportControl can be used to delete a control
that exists on a form/report in design mode.  Both of these functions
require a string value that represents the name of the form and a string
value that represents the name of the control.
 
DeleteControl and DeleteReportControl are commands - not functions.
They do not return a value.
 
The example below creates a form, then creates a button on the form,
displays a message, then deletes the button on the form:
 
   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/report
is not iconized.  The control still appears as if it were not deleted
even though you could not click it into focus.  To make the deleted
control disappear in such a case, you would have to repaint the form
design window by minimizing and restoring it.
 
If you have a report available in design mode, you can create groups
for it programmatically by using the CreateGroupLevel() function.  The
syntactical structure of CreateGroupLevel() is shown below:
 
   Function CreateGroupLevel(ReportName$,Expression$,
                             HasHeader$, HasFooter$)
 
ReportName is a string expression that indicates the name of the Report.
 
Expression is a string expression that represents the field name or
calculated field on which the group will be based.
 
HasHeader and HasFooter indicate whether the group includes a group
header or group footer, respectively.
 
When CreateGroupLevel() is executed, it adds a group at the innermost
level.  For example, if one group already exists, CreateGroupLevel()
will create a second group within the first group.  CreateGroupLevel()
returns a number indicating which level it created, beginning with zero.
In the example just mentioned, CreateGroupLevel() would return 1 since
it is the second group, and the first group was Group 0.

===========================================================================

