ACC: How to Run MS Access Wizards Using Visual Basic
ID: Q148506
|
The information in this article applies to:
-
Microsoft Access versions 7.0, 97
SUMMARY
Advanced: Requires expert coding, interoperability, and multiuser
skills.
This article describes how to start the Microsoft Access 97 and
Microsoft Access 7.0 wizards by using Visual Basic for Applications.
CAUTION: If you plan to create a custom application using the
Microsoft Access Developer's Toolkit (ADT) for Windows 95 or the
Microsoft Office 97 Developers Edition (ODE), you should not
programmatically start the Microsoft Access. Since you cannot
distribute the required library files with your application, any
Visual Basic code that runs the wizards can fail in the run-time
environment. You must have a single, licensed copy of Microsoft
Access for Windows 95 or Microsoft Access 97 installed on your
computer to run the Microsoft Access Wizards by using the methods
described in this article.
MORE INFORMATION
In Microsoft Access 97, the procedures for running the Wizards
are contained in the Wzmain80.mde and Wztool80.mde library
databases, which are located in your Microsoft Office folder (for
example, C:\Msoffice\Office).
In Microsoft Access 7.0 for Windows 95, the procedures for
running the Wizards are contained in the Wzmain70.mda and
Wztool70.mda library databases, which are located in your
Microsoft Access folder (for example, C:\Msoffice\Msaccess).
The Wzmain80.mde and Wzmain80.mde library databases contain the
following procedures for specific wizards:
Wizard Procedures
---------------------------------------------------------------------
Form frui_Entry([TableName as String], ObjectType _
Report as Integer)
Simple Query
Crosstab Query xtq_Entry()
AutoForm: Columnar auto_Entry(TableName as String, DocumentType _
AutoForm: Datasheet as Integer, ObjectType as Integer)
AutoForm: Tabular
AutoReport: Columnar
AutoReport: Tabular
PivotTable pvt_Entry([TableName as String])
Word for Windows Merge pm_Entry(TableName as String)
MailingLabel mlbl_Entry(TableName as String)
Table tw_Entry()
The Wztool80.mde and the Wztool80.mde library databases contain
the following procedures for specific wizards:
Wizard Procedures
------------------------------------------------------------------
Attachment att_Entry()
Form Chart cw_WizardEntry(TableName as String, _
Report Chart ObjectType as Integer, Unused as Integer)
Find Duplicates Query dup_Entry()
Find Unmatched Query dwz_Entry()
Calling the Wizards
When you call a procedure in a library database, the required
syntax can vary, depending on if you have a reference to the
library within your database.
Syntax with a Reference
If your database has a reference to Wztool80.mde and Wzmain80.mde
(Microsoft Access 97) or Wztool70.mda and Wzmain70.mda (Microsoft
Access 7.0), you can call the wizard procedures using standard
syntax for running a function or subroutine. For example, to
start a specific wizard from a form, you can copy the sample
syntax below to the OnClick property of a command button on the
form:
Wizard Calling Syntax
---------------------------------------------------------
Attachment =att_Entry()
AutoForm: Columnar =auto_Entry("Customers", 1 , 2 )
AutoForm: Datasheet =auto_Entry("Customers", 3 , 2 )
AutoForm: Tabular =auto_Entry("Customers", 2 , 2 )
AutoReport: Columnar =auto_Entry("Customers", 1 , 3 )
AutoReport: Tabular =auto_Entry("Customers", 2 , 3 )
Crosstab Query =xtq_Entry()
Find Duplicates Query =dup_Entry()
Find Unmatched Query =dwz_Entry()
Simple Query =frui_Entry("Customers",1)
Form =frui_Entry("",2)
Form Chart =cw_WizardEntry("Customers",2,0)
MailingLabel =mlbl_Entry("Customers")
PivotTable =pvt_Entry([TableName as String])
Report =frui_Entry("Customers" ,3)
Report Chart =cw_WizardEntry("Customers",3,0)
Table =tw_Entry()
Word for Windows Merge =pm_Entry("Customers")
NOTE: You cannot programmatically create a reference using Visual
Basic. It must be created manually. The basic steps are as follows:
- Open your database in which you want to start the wizards
from Visual Basic.
- Open a module in Design view.
- On the Tools menu, click References.
- If the libraries appear in the list of available
references, ensure that their check boxes are checked and
click OK. If these libraries are not listed, then click
the Browse button and proceed with step 5.
- In the Add Reference box, Select "Databases *.MDB, *.MDA"
from the Files Of Type list, and then locate the
Wzmain80.mde or Wztool80.mde. Note that these files are
typically installed in the Microsoft Office folder in the
subfolder, Office (for example, C:\Msoffice\Office).
NOTE: In Microsoft Access 7.0 for Windows 95, you would look
for Wzmain70.mda or Wztool70.mda, typically located in the
Microsoft Access folder (for example, C:\Msoffice\Msaccess).
- Once you locate the library (for example Wzmain80.mde),
select the file name and click OK. The library name
should then appear in the References box with a check
mark. Click OK to close the References box.
Syntax Using a Reference
If you want to avoid creating a reference to Wztool80.mde
and Wzmain80.mde (Microsoft Access 97) or Wztool70.mda and
Wzmain70.mda (Microsoft Access 7.0), you can use the Run
method of the Application object in a Visual Basic procedure
to call a wizard, for example:
Application.Run "<library>.<function>", [arguments]
To start a specific wizard, use Application.Run with the
sample "library.function" syntax in the table below:
Wizard "<library>.<function>"
-----------------------------------------------------------------------
Attachment "Wztool80.att_Entry"
AutoForm: Columnar "Wzmain80.auto_Entry", "Customers",1,acForm
AutoForm: Datasheet "Wzmain80.auto_Entry", "Customers",3,acForm
AutoForm: Tabular "Wzmain80.auto_Entry", "Customers",2,acForm
AutoReport: Columnar "Wzmain80.auto_Entry", "Customers",1,acReport
AutoReport: Tabular "Wzmain80.auto_Entry", "Customers",2,acReport
Crosstab Query "Wzmain80.xtq_Entry"
Find Duplicates Query "Wztool80.dup_Entry"
Find Unmatched Query "Wztool80.dwz_Entry"
Simple Query "Wzmain80.frui_Entry", "Customers",acQuery
Form "Wzmain80.frui_Entry", "",acForm
Form Chart "Wztool80.cw_WizardEntry", "Customers",acForm,0
MailingLabel "Wzmain80.mlbl_Entry", "Customers"
PivotTable "Wzmain80.pvt_Entry","Customers"
Report "Wzmain80.frui_Entry", "Customers" ,acReport
Report Chart "Wztool80.cw_WizardEntry", "Customers",acReport,0
Table "Wzmain80.tw_Entry"
Word for Windows Merge "Wzmain80.pm_Entry", "Customers"
NOTE: In Microsoft Access 7.0 for Windows 95, you use the
same syntax except you use a 7 instead of an 8 in the
library name. For instance, the Attachment Wizard would be
referred to as "Wztool70.att_Entry in Microsoft Access 7.0"
REFERENCES
Microsoft Access "Building Applications with Microsoft Access 97," Chapter
12, "Using Library Databases and Dynamic-Link Libraries," pages 353-369.
Microsoft Access "Building Applications with Microsoft Access for Windows
95," version 7.0, Chapter 12, "Using Library Databases and Dynamic-Link
Libraries," pages 292-294.
For more information about starting Microsoft Wizards in Microsoft Access
version 2.0, please see the following article in the Microsoft Knowledge
Base:
Q115121 ACC2: How to Start MS Access Wizards with WLib_WizMain
Function
Keywords : kbusage WzHowto
Version : 7.0
Platform : WINDOWS
Issue type : kbhowto