C
charles-guillaume.harika
Hello world,
My problem :
I create in a module from db1 a new database db2 by the instruction:
DBEngine.CreateDatabase(Application.CurrentProject.Path &
"\Compacter.mdb", dbLangGeneral, False)
then I create from db1 a module (called "Comapcting") in the db2
thanks to:
objAccess.OpenCurrentDatabase Application.CurrentProject.Path &
"\Compacter.mdb", False
objAccess.DoCmd.RunCommand acCmdNewObjectModule
objAccess.DoCmd.Save acModule, objAccess.Modules(0).name
objAccess.DoCmd.Rename "Compacting", acModule,
objAccess.Modules(0).name
I write some code in this module by th instruction:
objAccess.Modules("Compacting").InsertText "code I want to appear in
the new module"
HERE is THE Problem: the command .InsertText open the VBE window of
the db2
I would like to know if it's possible to hide this VBE Window. I
already hide the main Access window with:
apiShowWindow(objAccess.hWndAccessApp, 0) '0 is the constant in order
to Hide the window
Do you know how to know the handle of the VBE window ? In this case I
would use the apiShowWindow function.
Or is there another way to hide the VBE window ?
I put here my entire code:
Option Compare Database
Public Declare Function apiShowWindow Lib "user32" Alias
"ShowWindow" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Public Function db_compact()
On Error GoTo Erreur
Dim objAccess As New Access.Application
Dim dbs As DAO.Database
Dim ref As Reference
Dim new_name As String
Dim tmp_name As String
Set dbs = DBEngine.CreateDatabase(Application.CurrentProject.Path &
"\Compacter.mdb", dbLangGeneral, False) 'Creation of the db2
dbs.Close
Set dbs = Nothing
objAccess.OpenCurrentDatabase Application.CurrentProject.Path &
"\Compacter.mdb", False
Call apiShowWindow(objAccess.hWndAccessApp, 0)
objAccess.DoCmd.RunCommand acCmdNewObjectModule 'Creation of a new
module in db2
objAccess.DoCmd.Save acModule, objAccess.Modules(0).name
objAccess.DoCmd.Rename "Compacting", acModule,
objAccess.Modules(0).name
objAccess.Modules("Compacting").InsertText "dadada" 'Inserting code in
the created module of db2
objAccess.DoCmd.Save acModule, "Compacting"
objAccess.DoCmd.Close acModule, "Compacting", acSaveYes
objAccess.CloseCurrentDatabase
Set objAccess = Nothing
Erreur:
End Function
My problem :
I create in a module from db1 a new database db2 by the instruction:
DBEngine.CreateDatabase(Application.CurrentProject.Path &
"\Compacter.mdb", dbLangGeneral, False)
then I create from db1 a module (called "Comapcting") in the db2
thanks to:
objAccess.OpenCurrentDatabase Application.CurrentProject.Path &
"\Compacter.mdb", False
objAccess.DoCmd.RunCommand acCmdNewObjectModule
objAccess.DoCmd.Save acModule, objAccess.Modules(0).name
objAccess.DoCmd.Rename "Compacting", acModule,
objAccess.Modules(0).name
I write some code in this module by th instruction:
objAccess.Modules("Compacting").InsertText "code I want to appear in
the new module"
HERE is THE Problem: the command .InsertText open the VBE window of
the db2
I would like to know if it's possible to hide this VBE Window. I
already hide the main Access window with:
apiShowWindow(objAccess.hWndAccessApp, 0) '0 is the constant in order
to Hide the window
Do you know how to know the handle of the VBE window ? In this case I
would use the apiShowWindow function.
Or is there another way to hide the VBE window ?
I put here my entire code:
Option Compare Database
Public Declare Function apiShowWindow Lib "user32" Alias
"ShowWindow" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Public Function db_compact()
On Error GoTo Erreur
Dim objAccess As New Access.Application
Dim dbs As DAO.Database
Dim ref As Reference
Dim new_name As String
Dim tmp_name As String
Set dbs = DBEngine.CreateDatabase(Application.CurrentProject.Path &
"\Compacter.mdb", dbLangGeneral, False) 'Creation of the db2
dbs.Close
Set dbs = Nothing
objAccess.OpenCurrentDatabase Application.CurrentProject.Path &
"\Compacter.mdb", False
Call apiShowWindow(objAccess.hWndAccessApp, 0)
objAccess.DoCmd.RunCommand acCmdNewObjectModule 'Creation of a new
module in db2
objAccess.DoCmd.Save acModule, objAccess.Modules(0).name
objAccess.DoCmd.Rename "Compacting", acModule,
objAccess.Modules(0).name
objAccess.Modules("Compacting").InsertText "dadada" 'Inserting code in
the created module of db2
objAccess.DoCmd.Save acModule, "Compacting"
objAccess.DoCmd.Close acModule, "Compacting", acSaveYes
objAccess.CloseCurrentDatabase
Set objAccess = Nothing
Erreur:
End Function