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

Security code for linked tables 1

Status
Not open for further replies.

abd1311

MIS
Aug 19, 2007
22
QA
Hi,
I am trying to connect to another db using the following code:

Code:
Dim db As Database
Dim con As Container
Dim doc As Document
Dim newLink As TableDef

Set db = CurrentDb()
Set newLink = db.CreateTableDef("WebResume")
newLink.Connect = ";DATABASE=" & dbPath & dbName
newLink.SourceTableName = "WebResume"
db.TableDefs.Append newLink

Set con = db.Containers("Tables")
Set doc = con.Documents("WebResume")

doc.Permissions = dbSecRetrieveData
doc.UserName = "Admin"
doc.Permissions = dbSecRetrieveData
doc.UserName = "Users"
doc.Permissions = dbSecRetrieveData
Debug.Print "New AllPermissions: " & doc.AllPermissions

the code works fine if the db is in my computer
but, usually the dbPath is a path for an Access db on a server, which requires a username and a password
sure this code will not work in such case, cos it needs the username and the password, so is there a way to slip (as parameters) the username and password in the above code? i am not that much into vba coding

any help will be appreciated
 
newLink.Connect = "User ID=Username;PWD=Password;DATABASE=" & dbPath & dbName

should do it.

John
 
Thank you John for your reply
i did exactly what you said, but i got this error message about "Could not find installable ISAM"
i went to the article to find a solution and did exactly what is in the article, but still having the same error message, i got it on the Append line..
 
A slightly different method mentioned in

is:

newLink.Connect = "UID=Username;PWD=Password;DATABASE=" & dbPath & dbName

I am assuming that the dbPath and dbName variables are declared as input parameters to your code as they are not explicitly declared and set.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top