Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

vbs/access file

Posted on 2004-09-21
3
Medium Priority
?
214 Views
Last Modified: 2010-05-02
Hi,

how do i create a vbs or exe? that would create a new MS Access file in a certain directory for a
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?
0
Comment
Question by:testn1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 7

Expert Comment

by:kmorris1186
ID: 12117044
You can create a Access Database using this code:

Set appAccess = CreateObject("Access.Application")
appAccess.NewCurrentDatabase "c:\test.mdb"

i am unsure about setting the password, etc..

This will create an Access DB for the version of Access that is installed on the users machine.
this also means, No Access, No Database.
0
 
LVL 4

Expert Comment

by:avi247
ID: 12118063
Sub CreateDatabase(DatabaseName As String, Password As String)

'Ref:
' http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odeopg/html/deovropeningaccessdatabasebyusingado.asp
' http://support.microsoft.com/?kbid=304915

   Dim objCat As Object 'New ADOX.Catalog
   Dim objConn As Object 'ADODB.Connection
   Dim strAlter As String

    ' create the database
    Set objCat = CreateObject("ADOX.Catalog")
    objCat.Create "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\" & DatabaseName & ";Jet OLEDB:Engine Type=5"
    Set objCat = Nothing
   
   
   
    ' set the password
    Set cn = CreateObject("ADODB.Connection")
    objConn.Mode = adModeShareExclusive 'opens in exclusive mode
    objConn.Open "Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\" & DatabaseName & ";Uid=;Pwd="
    strAlter = "ALTER Database Password " & Password & "``"
    objConn.Execute strAlter
    Set objConn = Nothing

End Sub
0
 
LVL 4

Accepted Solution

by:
avi247 earned 2000 total points
ID: 12118158
Oops! Sorry. posted incorrect code above for Setting the Password.. Heres it again. Other things remain same.


    ' set the password
    Set objConn = CreateObject("ADODB.Connection")
    objConn.Mode = adModeShareExclusive 'opens in exclusive mode
    objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data source=C:\TestDB.mdb;Persist Security info=False"
    strAlter = "ALTER Database Password " & Password & " NULL"
    objConn.Execute strAlter
    Set objConn = Nothing

0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question