creating a new MS access DB

  • Thread starter Thread starter Albretch
  • Start date Start date
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?
 
I don't believe it's possible to do using a Batch file. You might be able to
use VBScript to do it, by Automating Access, but Batch files just don't have
that sort of capability.
 
Douglas J. Steele said:
I don't believe it's possible to do using a Batch file. You might be able to
use VBScript to do it, by Automating Access, but Batch files just don't have
that sort of capability.

Well, maybe not exactly a plain batch file, but there should be a way
to do it using some kind of automation within a Windows box with
Access installed.

How is it then the OS does it?
 
Albretch said:
"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message

Well, maybe not exactly a plain batch file, but there should be a way
to do it using some kind of automation within a Windows box with
Access installed.

How is it then the OS does it?

The OS is capable of doing Automation. As I indicated, VBScript should be
capable of doing this as well.

On the other hand, this is a rather unusual requirement you have. Maybe if
you explained why you're trying to do this, someone can suggest a better
approach.
 
The OS is capable of doing Automation.
That any code snippet doing what the OS does should as well
As I indicated, VBScript should be capable of doing this as well.
SHould I then demand from users to have installed VBScript?
On the other hand, this is a rather unusual requirement you have. Maybe if
you explained why you're trying to do this, someone can suggest a better
approach.
Exactly as I said in my first post and why is that so unusual?
 
Your original post does not say why you had this need, it only says what you
are trying to do. Wanting to be able to create a database from outside of
Access is certainly not a common requirement. Typically, if you need a
database, it's because you're going to use it in conjunction with an
application. That application would have the "responsibility" of creating
the database for its use.
 
I never said I wanted to created a MS Access DB in a machine where
people don't have access installed. Quoting myself:

// - - - - - - - - - - - - - - - - - -
. . . 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.
// - - - - - - - - - - - - - - - - - -

What I said was that I wanted to created a MS Access database -via a
batch file- (that would certainly call MS Access via the OS).

I still don't get why this requires such a big deal of extra
explanations

I know there must be a way
 
Back
Top