ACC97: "Convert Macros to Visual Basic" Converts Incorrectly

Last reviewed: April 17, 1997
Article ID: Q167061
The information in this article applies to:
  • Microsoft Access 97

SYMPTOMS

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

When you run the "Convert Macros to Visual Basic" command on a macro that has any of the following RunCommand actions

   RunCommand ArrangeIconsByCreated
   RunCommand ArrangeIconsByModified
   RunCommand ArrangeIconsByName
   RunCommand ArrangeIconsByType
   RunCommand StepInto
   RunCommand FindNext
   RunCommand HyperlinkDisplayText

the macro actions are converted to the following methods of the DoCmd object in the module

   DoCmd.RunCommand acCmdSortByCreated    (ArrangeIconsByCreated)
   DoCmd.RunCommand acCmdSortByModified   (ArrangeIconsByModified)
   DoCmd.RunCommand acCmdSortByName       (ArrangeIconsByName)
   DoCmd.RunCommand acCmdSortByType       (ArrangeIconsByType)
   DoCmd.RunCommand <blank>               (StepInto)
   DoCmd.RunCommand <blank>               (FindNext)
   DoCmd.RunCommand acCmdEnterEditMode    (HyperlinkDisplayText)

and you receive the following compile error when you try to compile the module:

   Compile error

   Variable not defined.

CAUSE

The "Convert Macros to Visual Basic" command on the Macro submenu, incorrectly converts the macro actions.

RESOLUTION

You must manually change the syntax for the RunCommand actions in the module.

MORE INFORMATION

The following table lists the correct syntax for the converted macro actions.

Converted Syntax                    Correct Syntax

RunCommand ArrangeIconsByCreated    DoCmd.RunCommand acCmdArrangeIconsBy
                                    Created.

RunCommand ArrangeIconsByModified   DoCmd.RunCommand acCmdArrangeIconsBy
                                    Modified.

RunCommand ArrangeIconsByName       DoCmd.RunCommand acCmdArrangeIconsBy
                                    Name.

RunCommand ArrangeIconsByType       DoCmd.RunCommand acCmdArrangeIconsBy
                                    Type.

RunCommand StepInto                 DoCmd.RunCommand acCmdStepInto.

RunCommand FindNext                 DoCmd.RunCommand acCmdFindNext.

RunCommand HyperlinkDisplayText     DoCmd.RunCommand acCmdHyperlinkDisplay
                                    Text.

Steps to Reproduce Behavior

  1. Open a new database in Microsoft Access 97.

  2. Create a new macro and add the following actions to the macro:

          Macro Name           Macro Action
          ---------------------------------
          Macro1               RunCommand
                               RunCommand
                               RunCommand
                               RunCommand
                               RunCommand
                               RunCommand
                               RunCommand
    
          Macro1 Actions
          ----------------------------------
          RunCommand
             Command: ArrangeIconsByCreated
          RunCommand
             Command: ArrangeIconsByModified
          RunCommand
             Command: ArrangeIconsByName
          RunCommand
             Command: ArrangeIconsByType
          RunCommand
             Command: StepInto
          RunCommand
             Command: FindNext
          RunCommand
             Command: HyperlinkDisplayText
    
    

  3. Save the macro as Macro1 and close it.

  4. Select Macro1 in the Database window, and then on the Tools menu, point to Macro, and click "Convert Macros to Visual Basic."

  5. After the module has been created, open it in Design view, and then on the Debug menu, click Compile Loaded Modules. Note that you receive the compile error mentioned in the "Symptoms" section.

REFERENCES

For more information about converting macros, search the Help Index for "macros, converting," and then "convert macros to Visual Basic," or ask the Microsoft Access 97 Office Assistant.


Keywords : CnvErrs kberrmsg McrActn
Version : 97
Platform : WINDOWS
Issue type : kbprb
Resolution Type : kbworkaround


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: April 17, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.