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

Jebry...phm... Access bd password

Status
Not open for further replies.

fabiola

Programmer
Nov 13, 2001
3
MX
I have a bd with password and i have it in a server, and my users have the program in their own computer.

how can i open the bd with VBA from the program????

i don't want the users have the password.

i have 2 procedure, but i don't know how to use... or where??

Dim dbs As Database
Const conFilePath = "C:\SistDemandas\respaldo\"
' Open database for shared, read/write access, and specify database password.
Set dbs = OpenDatabase(conFilePath & "SistDemandasDatos1010011.mdb", False, False, ";pwd=mongol")

or

Dim wrk As Workspace
Dim dbProtected As Database

Set wrk = DBEngine.Workspaces(0)
Set dbProtected = wrk.OpenDatabase("c:\SistDemandas\respaldo\SistDemandasDatos1010011.mdb", False, False, ";PWD=mongol")

please help me...

thanks... :)
 
Fabiola,

Place this code behind a button:

Dim dbs As Database
Const conFilePath = "C:\SistDemandas\respaldo\"
' Open database for shared, read/write access, and specify database password.
Set dbs = OpenDatabase(conFilePath & "SistDemandasDatos1010011.mdb", False, False, ";pwd=mongol")

If using Acc 2000 password protect your code. That way your DB password is hidden to users.
If using Acc 97 u could always create an MDE (which would effictively remove the code so users couldn't see your hard coded password)

Nick
 
Hi try this function.

Function GetSecureDb(strDbPath As String, _
strUser As String, _
strPassword As String, _
strWrkgrpPath As String) As Boolean

' This function opens a secured Access database from Automation.
' It takes the following arguments:
' strDbPath = full path to the secured database
' strUser = name of the user account to open the database
' strPassword = password of strUser
' strWkgrpPath = full path to the workgroup information file
' that contains strUser account

Dim acApp As Access.Application
Dim strCommand As String

Const APP_PATH As String = "c:\program files\microsoft office\office\msaccess.exe"

' Build Access command line to pass to Shell function.
strCommand = """" & APP_PATH & """" & " " & """" & strDbPath & """" _
& " /User" & strUser & " /Pwd " & strPassword _
& "/NoStartup" & " /Wrkgrp " & strWrkgrpPath

' Pass command line to Shell function. If this succeeds, pass
' the database path to the GetObject function and loop until
' the acApp object variable is initialized.
If Shell(strCommand) Then
Do
On Error Resume Next
Set acApp = GetObject(strDbPath)
DoEvents
Loop Until Err.Number = 0
End If

' Sample command to open an Access form named "Categories".
acApp.DoCmd.OpenForm "Categories"

GetSecureDb = True

' Quit and destroy object variable.
acApp.Quit
Set acApp = Nothing
End Function Best Regards

---
JoaoTL
NOSPAM_mail@jtl.co.pt
 
Hi!

It seems to me that you got some good answers here assuming all you want to do it open the database in a place or two from your user's database. If you need to use the protected database throughout your other database then you will have code like Nick's all over and hiding it becomes more of a problem. One thing I want to add to Nick's post is that you can create an MDE in Access2k also, you will find the command in the tools menu. You may want to post with a clearer indication of what you are trying to accomplish, there may be other things you can do to maintain the security of the data and allow easier access to it.

Jeff Bridgham
bridgham@purdue.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top