Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating an password protected access database at runtime..

Status
Not open for further replies.

wraygun

Programmer
Dec 9, 2001
272
US
I'm using something like the following to create an access database. I would like to add a password programmatically. Is it even possible? All the examples I found suggest doing it in access, however for my needs that won't work. Any help will be greatly appreciated.

Code:
Dim db As Database
Dim td As TableDef
Dim f1 As Field

'Create the database
Set db = CreateDatabase(App.Path & "\sonic.mdb", dbLangGeneral)

'Create First Table
Set td = db.CreateTableDef("EmployeeInfo")

'Add Fields via Custom Sub
AddField "Employee #"
AddField "Last Name"
AddField "First Name"
AddField "Middle Initial"
AddField "Address"
AddField "City"
AddField "State"
AddField "Zip Code"
AddField "Pay Rate"
AddField "SSN"
AddField "Active"
AddField "Phone Number"

db.TableDefs.Append td

db.Close

Thanks,
Harold

***You can't change your past, but you can change your future***
 
Solved this one myself. Small miracles can happen.

For anyone that's interested, courtesy of microsoft:

Code:
Dim DB As Database
     Dim tblDef As TableDef, fld As Field

     Set DB = DBEngine.Workspaces(0).CreateDatabase("C:\Atest.mdb", _
         dbLangGeneral, dbEncrypt)
     DB.NewPassword "", "aaa"
     ' Create new TableDef.
     Set tblDef = DB.CreateTableDef("Table1")
     ' Add field to tblDef.
     Set fld = tblDef.CreateField("Field1", dbInteger)
     tblDef.Fields.Append fld
     ' Save TableDef definition by appending it to TableDefs collection.
     DB.TableDefs.Append tblDef
     DB.Close
     MsgBox "Atest.mdb and Table1 is created."

Thanks,
Harold

***You can't change your past, but you can change your future***
 
What references do i need to put into my project to be able to run this example?

thnx
 
Microsoft DAO 3.6 Object Library

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top