Creating a password for another database

M_Mike

Registered User.
Local time
Today, 07:47
Joined
Aug 10, 2005
Messages
31
I have create a vb script that creates a new empty database when a command button is clicked. I have then created macros to populate the nwe database. Is there any way to set a password automatically for this database after the new tables have been generated, without the user having to set it manually (the password will always be the same).
 
Found this on the web but is uses VBA rather than VB script:-

Create MS Access database and lock it with password from VB code

Description: This VB project creates a Microsoft Access database and lock it with a specified password. The database contains no tables (tables can be created either using code or in MS Access).

Keywords: Microsoft Access database, Create database from VB code, Lock database with password, Database in VB, Password locked database, lock MS Access database


'Note: This code requires a reference to the DAO object library--------------------------------------------------------------------------------

Private Sub Command1_Click()

Dim wrkDefault As Workspace
Dim dbsNew As Database

'Get default Workspace.
Set wrkDefault = DBEngine.Workspaces(0)

'Set the database filename
DBFilename = App.Path & "\mydb.mdb"

'Make sure there isn't already a file with the same name of
'the new database file.
If Dir(DBFilename) <> "" Then
MsgBox "File already exists!"
Exit Sub
End If

'Create a new encrypted database with the specified
'collating order.
'lock database with the password 'hello'
Set dbsNew = wrkDefault.CreateDatabase(DBFilename, _
dbLangGeneral & ";pwd=hello;", dbEncrypt)

'Note: Above, you can use (dbEncrypt Or dbVersion25) to specify
'the database version:
'dbVersion10 for Access version 1.0
'dbVersion11 for Access version 1.1
'dbVersion20 for Access version 2.0
'dbVersion25 for Access version 2.5
'dbVersion30 for Access version 3.0
'dbVersion35 for Access version 3.5
'Database versions below 2.5 do not support password locking

dbsNew.Close


End Sub
 

Users who are viewing this thread

Back
Top Bottom