ACC95: How to Run MS Access Wizards Using Visual Basic

Last reviewed: May 13, 1997
Article ID: Q148506
The information in this article applies to:
  • Microsoft Access version 7.0

SUMMARY

Advanced: Requires expert coding, interoperability, and multiuser skills.

This article describes how to start the Microsoft Access version 7.0 wizards 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, you should not programmatically start the Microsoft Access Wizards in your database. Any Visual Basic code that runs the wizards can fail in the run-time environment because you cannot distribute the required library files with your application. You must have a single, licensed copy of Microsoft Access for Windows 95 installed on your computer to run the Microsoft Access Wizards using the methods described in this article.

MORE INFORMATION

The procedures for running the Microsoft Access Wizards are contained in the Wzmain70.mda and Wztool70.mda library databases, which are located in your Microsoft Access folder (for example, C:\Msoffice\Access).

The Wzmain70.mda library database contains 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 Wztool70.mda library database contains 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 the Wztool70.mda or Wzmain70.mda 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 Wztool70.mda and Wzmain70.mda, 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:

  1. Open your database in which you want to start the wizards from Visual Basic.

  2. Open a module in Design view.

  3. On the Tools menu, click References.

  4. If the Wzmain70.mda and Wztool70.mda 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.

  5. In the Add Reference box, Select "Databases *.MDB, *.MDA" from the Files Of Type list, and then locate the Wzmain70.mda or Wztool70.mda. Note that these files are typically installed in the Microsoft Access main folder (for example, C:\Msoffice\Access).

  6. Once you locate the library (for example Wzmain70.mda), 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 Wztool70.mda and Wzmain70.mda, 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 following sample "library.function" syntax:

 Wizard                   "<library>.<function>"
 -----------------------------------------------------------------------

 Attachment               "Wztool70.att_Entry"
 AutoForm: Columnar       "Wzmain70.auto_Entry", "Customers",1,acForm
 AutoForm: Datasheet      "Wzmain70.auto_Entry", "Customers",3,acForm
 AutoForm: Tabular        "Wzmain70.auto_Entry", "Customers",2,acForm
 AutoReport: Columnar     "Wzmain70.auto_Entry", "Customers",1,acReport
 AutoReport: Tabular      "Wzmain70.auto_Entry", "Customers",2,acReport
 Crosstab Query           "Wzmain70.xtq_Entry"
 Find Duplicates Query    "Wztool70.dup_Entry"
 Find Unmatched Query     "Wztool70.dwz_Entry"
 Simple Query             "Wzmain70.frui_Entry", "Customers",acQuery
 Form                     "Wzmain70.frui_Entry", "",acForm
 Form Chart               "Wztool70.cw_WizardEntry", "Customers",acForm,0
 MailingLabel             "Wzmain70.mlbl_Entry", "Customers"
 PivotTable               "Wzmain70.pvt_Entry","Customers"
 Report                   "Wzmain70.frui_Entry", "Customers" ,acReport
 Report Chart             "Wztool70.cw_WizardEntry", "Customers",acReport,0
 Table                    "Wzmain70.tw_Entry"
 Word for Windows Merge   "Wzmain70.pm_Entry", "Customers"

REFERENCES

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:

   ARTICLE-ID: Q115121
   TITLE:      ACC2: How to Start MS Access Wizards with WLib_WizMain
               Function
 

	
	


Keywords : kbusage WzHowto
Version : 7.0
Platform : WINDOWS
Hardware : X86
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: May 13, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.