ACC97: New Module in Microsoft Access 97 Not Saved If Empty (175218)
The information in this article applies to:
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.
REFERENCES
For more information about creating modules, search the Help Index for
"modules, overview," or ask the Microsoft Access 97 Office Assistant.
Modification Type: | Major | Last Reviewed: | 9/26/2003 |
---|
Keywords: | kbprb KB175218 |
---|
|