A
Albretch
I need to create a new MS Access DB file from a batch file and I think
this should be possible, since there are OS utilities to do so. Inside
of a folder you can get its context right clicking on it and select
'New -> MS Access DB', so there should be a way to do in a batch/OS
command without angaging a VBA macro. Am I right?
The batch file should accept a string with the folder/file name (and
optionally, certain user with her password) and it should work on an
OS level for the version of access users have instaled in their local
boxes.
Using VBA code you can attain this by going:
// - - - - - - - - - - - - -
Function createMSAccessDB(strDBPath As String, strUId As String, strPW
As String)
Dim db As Database
Set db = DBEngine.CreateDatabase(strDBPath, dbLangGeneral)
db.NewPassword strUId, strPW
db.Close
Set db = Nothing
End Function
or
.. . .
Function createMSAccessDB(strDBPath As String, strUId As String, strPW
As
String)
strCmd As String
strCmd = SysCmd(acSysCmdAccessDir) & "\MSAccess.exe " _
& strDBPath & " /wrkgrp " & DBEngine.SystemDB _
& " /user " & strUId & " /pwd " & strPW
Call Shell(strCmd, vbNormalFocus)
DoEvents: DoEvents: DoEvents:
Stop
End Function
.. . .
// __
How could you do this on an OS level using a batch file?
Is there a way to log the OS acctions while you are using it, so you
can do how it is done behind the scene?
this should be possible, since there are OS utilities to do so. Inside
of a folder you can get its context right clicking on it and select
'New -> MS Access DB', so there should be a way to do in a batch/OS
command without angaging a VBA macro. Am I right?
The batch file should accept a string with the folder/file name (and
optionally, certain user with her password) and it should work on an
OS level for the version of access users have instaled in their local
boxes.
Using VBA code you can attain this by going:
// - - - - - - - - - - - - -
Function createMSAccessDB(strDBPath As String, strUId As String, strPW
As String)
Dim db As Database
Set db = DBEngine.CreateDatabase(strDBPath, dbLangGeneral)
db.NewPassword strUId, strPW
db.Close
Set db = Nothing
End Function
or
.. . .
Function createMSAccessDB(strDBPath As String, strUId As String, strPW
As
String)
strCmd As String
strCmd = SysCmd(acSysCmdAccessDir) & "\MSAccess.exe " _
& strDBPath & " /wrkgrp " & DBEngine.SystemDB _
& " /user " & strUId & " /pwd " & strPW
Call Shell(strCmd, vbNormalFocus)
DoEvents: DoEvents: DoEvents:
Stop
End Function
.. . .
// __
How could you do this on an OS level using a batch file?
Is there a way to log the OS acctions while you are using it, so you
can do how it is done behind the scene?