Article ID: 175218
Article Last Modified on 1/22/2007
APPLIES TO
- Microsoft Access 97 Standard Edition
This article was previously published under Q175218
Moderate: Requires basic macro, coding, and interoperability skills.
SYMPTOMS
When you create a module in Microsoft Access 97, you are not prompted to save the module if you have not entered data into the module. In Microsoft Access 95, you are prompted to save the module even though the module is empty.
This behavior occurs in Microsoft Access 97 regardless of whether you are creating the module with code or you are creating the module manually.
CAUSE
The module must contain data before it can be saved.
RESOLUTION
When you want to create a module that will not have any code, add a procedure or function to the module before you save it. This will ensure that the module is saved. For example, the following procedure will create a new module, add a procedure to the module, and then save the module.
Sub CreateNewModule() Dim MyMod As Module Dim MyStr As String DoCmd.RunCommand acCmdNewObjectModule ' Create new module. MyStr = "Sub Test2()" & vbCrLf ' Create text for the module. MyStr = MyStr & Space$(4) & "MsgBox " & Chr$(34) & "test2" & _ Chr$(34) & vbCrLf MyStr = MyStr & "End Sub" Set MyMod = Modules("Module3") ' Give module a name. MyMod.InsertText MyStr ' Insert text into the module. DoCmd.Close acModule, "Module3", acSaveYes ' Close and save module. End Sub
STATUS
This behavior is by design.
MORE INFORMATION
Steps to Reproduce Behavior
- In Microsoft Access 97, create a module and type the following line in the Declarations section, if it is not already there:
Option Explicit
Type the following procedure in the module:
Sub CreateModule() DoCmd.RunCommand acCmdNewObjectModule DoCmd.Close acModule, "Module2", acSaveYes End Sub
- Save the module as Module1.
- Press CTRL+G to open the Debug window.
- To test this procedure, type the following line in the Debug window, and then press ENTER:
CreateModule
REFERENCES
For more information about creating modules, search the Help Index for "modules, overview," or ask the Microsoft Access 97 Office Assistant.
Additional query words: not dirty
Keywords: kbprb KB175218