MichaelRed
Programmer
Thread 705-153380 provided the function code below. I know it worked when posted for Ms. A. 2K. I am trying to use it I Ms. A 2003 and get a failure on the line indicated (to SAVE the newly created object). The error is :
Debug.Print err, Error(Err)
29068 Microsoft Office Access cannot complete this operation. You must stop the code and try again.
I have checked that each term in the statement is 'valid' in Ms. A 2003, as attempting a few work arounds (moving the save & subsequent commands to a separate function which is called seperatly ...) all to no avail.
I KNOIW it has worked, as I tried it when the original soloution was posted) Any one have an updated version of this, or suggestion(s)?
MichaelRed
Debug.Print err, Error(Err)
29068 Microsoft Office Access cannot complete this operation. You must stop the code and try again.
I have checked that each term in the statement is 'valid' in Ms. A 2003, as attempting a few work arounds (moving the save & subsequent commands to a separate function which is called seperatly ...) all to no avail.
I KNOIW it has worked, as I tried it when the original soloution was posted) Any one have an updated version of this, or suggestion(s)?
Code:
Public Function basModule_Make_II(strModName As String) As Boolean
Dim mdl As Module
Dim blnModSave As Boolean
DoCmd.SetWarnings False
' Create the module.
DoCmd.RunCommand acCmdNewObjectModule
' Set MyModule to be the new Module Object.
Set mdl = Application.Modules.Item(Application.Modules.Count - 1)
' Save, close, and rename the new Module.
DoCmd.Save acModule, save, mdl ' Error HERE
DoCmd.Close acModule, mdl, acSaveYes
DoCmd.Rename strModName, acModule, mdl
DoCmd.OpenModule strModName
Set mdl = Modules(strModName)
DoCmd.SetWarnings True
End Function
MichaelRed