Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create and Save Modules, Actually accompllished

Status
Not open for further replies.

MichaelRed

Programmer
Dec 22, 1999
8,410
0
0
US
After reviewing numerous threads

numerous small clues in several

allowing the turtle like speed of my 'brain'

...

The last and apparently most necessary: you MUST save AND compile all modules /[color] before creating one! Compile does NOT (as was pointed out) save the module (it appears to simply approve of the code as it exists).

from the Debug window:

strDwg = "Dwg_Test_4_Exe"
basModules_Main(strDwg)

then the following code created two modules

Code:
Public Function basModules_Main(strDwg As String)

    Dim blnDone As Boolean
    Dim Idx As Integer
    Dim strNewName(1) As String
    Dim strOldName As String
    Dim strTemp As String

    strNewName(0) = strDwg & "_Exe"
    strNewName(1) = strDwg & "_Test"

    Do While Idx <= UBound(strNewName)
        RunCommand acCmdCompileAndSaveAllModules
        strTemp = strNewName(Idx)
        strOldName = basModule_Make("XXX")
        blnDone = basCls_Sav_Ren(strOldName, strTemp)
        Idx = Idx + 1
    Loop

End Function
Public Function basCls_Sav_Ren(strOldName As String, strNewName As String)

        DoCmd.Close acModule, strOldName, acSaveYes
        DoCmd.Save acModule, strOldName
        DoCmd.Rename strNewName, acModule, strOldName

End Function
Public Function basModule_Make(strMod As String) As String

    Dim mdl As Module

    DoCmd.RunCommand acCmdNewObjectModule

    ' Set MyModule to be the new Module Object.
    Set mdl = Application.Modules.Item(Application.Modules.Count - 1)
    basModule_Make = mdl

End Function

Thanks to the several contributors who gave their insight(s)!!!




MichaelRed


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top