Microsoft KB Archive/168311

= ACC97: RunCommand Constants Truncated After 25 Characters =

Article ID: 168311

Article Last Modified on 1/19/2007

-

APPLIES TO


 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q168311



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



SYMPTOMS
When you convert any of the following RunCommand macro actions   RunCommand CompileAndSaveAllModules RunCommand ConvertMacrosToVisualBasic RunCommand CreateShortcutMenuFromMacro RunCommand HorizontalSpacingMakeEqual RunCommand MicrosoftAccessHelpTopics RunCommand ObjBrwFindWholeWordOnly RunCommand ObjBrwShowHiddenMembers RunCommand QueryTypeSQLDataDefinition RunCommand QueryTypeSQLPassThrough RunCommand UserLevelSecurityWizard RunCommand VerticalSpacingMakeEqual using the "Convert Macro to Visual Basic" command, the syntax is truncated during the conversion, and you receive the following error message when you compile the converted macro module:

Compile error:

Variable not defined



CAUSE
There is a 25 character limitation for the RunCommand constants when using the "Convert Macro to Visual Basic" command. This includes the acCmd prefix that is attached to the constant during the conversion.



RESOLUTION
To prevent your code from failing with a compile error, modify the syntax for the truncated constants before you compile and run the module.



Steps to Reproduce Behavior
 Create a new database in Microsoft Access 97.  Create a new macro, and add the following RunCommand actions to the macro:

     Macro Name           Macro Action -     Macro1               RunCommand RunCommand RunCommand

Macro1 Actions --     RunCommand Command: CompileAndSaveAllModules RunCommand Command: ConvertMacrosToVisualBasic RunCommand Command: UserLevelSecurityWizard  Save the macro as Macro1. Select Macro1 in the Database window. On the Tools menu, point to Macro, and then click "Convert Macro to Visual Basic."</li> After the conversion process is finished, open the converted macro module. Note the truncated constants.</li> On the Debug menu, click Compile Loaded Modules. Note that you receive the error message mentioned in the "Symptoms" section.</li></ol>

<div class="references_section">