ACC97: Cannot Use RunCommand acCmdSaveModuleAsText in Code (161087)
The information in this article applies to:
This article was previously published under Q161087 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.
This article assumes that you are familiar with Visual Basic for
Applications and with creating Microsoft Access applications using the
programming tools provided with Microsoft Access. For more information
about Visual Basic for Applications, please refer to the "Building
Applications with Microsoft Access 97" manual.
CAUSE
Microsoft Access cannot save a code module while code is running.
RESOLUTION
The following two methods describe how to save a code module
programmatically.
Method 1: Using the OutputTo method- Open the sample database Northwind.mdb.
- Create a module and type the following line in the Declarations
section if it is not already there:
- Type the following procedure:
Function SaveMod()
DoCmd.OutputTo acOutputModule, "Utility Functions"
End Function
- To test this function, type the following line in the Debug window,
and then press ENTER:
- The Output To dialog box appears and prompts you for the file name and file type to save the Utility Functions module.
Method 2: Using the RunCommand Macro Action- Open the sample database Northwind.mdb.
- Create the following new macro called SaveMod:
Macro Name Action
--------------------------
SaveMod OpenModule
RunCommand
SaveMod Actions
---------------------------------
OpenModule
Module Name: Utility Functions
Procedure Name: <Leave blank>
RunCommand
Command: SaveModuleAsText
- Save the macro, and then run it.
- The Save As Text dialog box appears and prompts you for the file name
and file type to save the Utility Functions module.
REFERENCES
For more information about the OutputTo method, search the Help Index for
OutputTo method.
For more information about the RunCommand method, search the Help Index
for RunCommand method.
Modification Type: | Minor | Last Reviewed: | 10/11/2006 |
---|
Keywords: | kberrmsg kbprb kbProgramming KB161087 |
---|
|