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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to change password by using vb code

Status
Not open for further replies.

anouly

Instructor
Joined
Mar 17, 2004
Messages
5
Location
LA
Hi all,

I have a boring task that is I have to keep changecolleagues are responsible for keeping the database secured so I have to change the password for the database very often.

Conventionally through the Tools menu, and then.... I find it is a slow process and boring.

If anyone would have suggest a code that I can make use of for do this task would be highly appreciated.

I mean if you can use the code I will create a form and it just does the change of password to the target database for me.

Thank you for any suggestion or tips.

--Anouly
 
I havent tried the following personally as never had the need to use passwords but found this on google.

simply create the form with the appropriate textboxes. write VBA code
to validate that the old password matches the existing one, then
execute the NewPassword method on a user object, passing in the old
and new passwords. I found the following sample code in the security FAQ --

Code:
Function faqChangePassword (ByVal strUser As String, _
         ByVal strPwd As String) As Integer

         Dim ws As Workspace
         Dim usr As User

         Set ws = DBEngine.Workspaces(0)
         Set usr = ws.Users(strUser)
      usr.NewPassword "", strPwd
     End Function

You can change the database password by using the NewPassword method on the Database object instead of a User object, but you have to know the old password.
 
There's code in the security FAQ to do this and several other nifty things. You can get the FAQ from MS or from my site.

==
Jeremy Wallace
AlphaBet City Dataworks
Access Databases for Non-Profit Organizations

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top