Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

make MS Access DB as password protected through Visual Basic Code

Posted on 2002-07-06
10
Medium Priority
?
185 Views
Last Modified: 2013-11-25
My problem is fairly simple. i have created a database through Visual Basic 6.0. The code successfully created the database but i want to make this newly created database file as password protected. Just like we can do password protected to our MS WORD document file so no one else can read the essential contents. i think i have described my problem please contact me if you still un sure...
i need it soon so i placed 500 points.
0
Comment
Question by:younus_malik
[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
10 Comments
 
LVL 5

Expert Comment

by:kcm76
ID: 7133522
0
 
LVL 5

Accepted Solution

by:
kcm76 earned 2000 total points
ID: 7133534
0
 
LVL 5

Expert Comment

by:kcm76
ID: 7133545
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 6

Expert Comment

by:pierrecampe
ID: 7133547
or if you use DAO you can use:

Dim db As DAO.Database
Set db = DBEngine.OpenDatabase("TheDatabase.mdb", True)
db.NewPassword "Oldpassword", "Newpassword"
db.Close

note that "Oldpassword" can be "" (for db's that do not yet have a password

0
 
LVL 33

Expert Comment

by:hongjun
ID: 7133550
Try the below function. You need to add DAO Object Library References.


Public Function SetDatabasePassword(DBPath As String, _
newPassword As String) As Boolean
   
'Usage: Password protect a database that previously had no
'password

'Parameters: sDBPath: Full Path to Access Database
'newPassword: the password
'returns true on success false otherwise

If Dir(DBPath) = "" Then Exit Function

Dim db As DAO.Database

On Error Resume Next
Set db = OpenDatabase(DBPath, True)
If Err.Number <> 0 Then Exit Function
db.newPassword "", newPassword
SetDatabasePassword = Err.Number = 0
db.Close

End Function


hongjun
0
 
LVL 33

Expert Comment

by:hongjun
ID: 7133552
pierrecampe, sorry for my similar post. I did not see your post when I am making my post.

hongjun
0
 
LVL 5

Expert Comment

by:kcm76
ID: 7133559
**************************************
Experts, pls contribute as much as possible, this would really help others who view this thread in paq section in future.
**************************************

http://www.mvps.org/access/modules/mdl0036.htm

************* Code Start *****************
Function foo()
    Dim db As Database
    Dim oAcc As Access.Application

    Const TMP = "fooz.mdb"

    Set db = DBEngine.CreateDatabase(TMP, _
                        dbLangGeneral)
    db.NewPassword "", "doooo"
    db.Close
    Set db = Nothing

    Set oAcc = New Access.Application
    Set db = oAcc.DBEngine.OpenDatabase(TMP, _
                            False, False, ";PWD=doooo")
    oAcc.OpenCurrentDatabase TMP
    db.Close
    Set db = Nothing
End Function
0
 
LVL 33

Expert Comment

by:hongjun
ID: 7133560
>>Experts, pls contribute as much as possible
I am touched by your hardworking contribution but I think that a specific solution targetted to the question would be enough.

hongjun
0
 
LVL 33

Expert Comment

by:hongjun
ID: 7133561
Regardless of the amount of points assigned.

hongjun
0
 

Author Comment

by:younus_malik
ID: 7133573
Thanks to all you Guys. you all come up with the correct and precise answers but i choose this man cause he replied me first and fast.
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

704 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