Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Macros / August 2004

Tip: Looking for answers? Try searching our database.

creating a new MS access DB

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Albretch - 27 Aug 2004 19:59 GMT
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?
Douglas J. Steele - 27 Aug 2004 23:09 GMT
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.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> 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
[quoted text clipped - 40 lines]
>  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?
Albretch - 28 Aug 2004 19:43 GMT
> 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?
Douglas J. Steele - 28 Aug 2004 21:52 GMT
> > 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
[quoted text clipped - 5 lines]
>
>  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.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

Albretch - 29 Aug 2004 09:57 GMT
> 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?
Douglas J. Steele - 29 Aug 2004 12:05 GMT
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.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> > The OS is capable of doing Automation.
>  That any code snippet doing what the OS does should as well
[quoted text clipped - 6 lines]
> > approach.
>  Exactly as I said in my first post and why is that so unusual?
Albretch - 30 Aug 2004 13:31 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.