Microsoft KB Archive/200646

= ACC2000: Cannot Use RunCommand acCmdSaveModuleAsText in Code =

Article ID: 200646

Article Last Modified on 12/12/2002

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q200646



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



SYMPTOMS
When you run code that contains the RunCommand method with the acCmdSaveModuleAsText constant, you may receive the following error message:

The command or action 'SaveModuleAsText' isn't available now.



CAUSE
Microsoft Access cannot save a code module while code is running.



RESOLUTION
You can use the following method to save a code module programmatically:  Open the sample database Northwind.mdb.  Create a module and type the following line in the Declarations section if it is not already there: Option Explicit   Type the following procedure: Function SaveMod DoCmd.OutputTo acOutputModule, "Utility Functions" End Function   To test this function, type the following line in the Immediate Window, and then press ENTER: ?SaveMod  The Output To dialog box appears and prompts you for the file name and file type to save the Utility Functions module.</ol>

<div class="moreinformation_section">

Steps to Reproduce Behavior
<ol> Open the sample database Northwind.mdb.</li>  Create a module and type the following line in the Declarations section if it is not already there: Option Explicit </li>  Type the following procedure: Function SaveModFail DoCmd.OpenModule "Utility Functions" DoCmd.RunCommand acCmdSaveModuleAsText End Function </li>  To test this function, type the following line in the Immediate window, and then press ENTER: ?SaveModFail Note that you receive the following error message:

The command or action 'SaveModuleAsText' isn't available now.

</li></ol>

<div class="references_section">