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

update from password protected database 1

Status
Not open for further replies.

clowns119

Programmer
Feb 20, 2005
15
US
Hi all,
I am working on a project and the database i have set up pulls data from another access database. I am using the docmd.transferdatabase command and it is working great, however the database i am pulling from is password protected. I know the passowrd and I want it to be automatically entered for the user so they are not prompted to enter a password when they click the button that runs the transferdatabase command, I searched everywere and all i can find is documentation on how to use a passowrd for a DSN database, however I want to try and keep this one DSNless if possible, please advise here is my code if it helps
Code:
Private Sub wingschedclick_Click()

On Error Resume Next
DoCmd.SetWarnings False
DoCmd.DeleteObject acTable, "B-2 Sched Data"
DoCmd.DeleteObject acTable, "Range Sched Data"
DoCmd.DeleteObject acTable, "AR Sched Data"
DoCmd.SetWarnings True
DoCmd.TransferDatabase acImport, "Microsoft Access", "\\Szl-fs-02\509oss\OSW\mission tracking\wingsched.mdb", acTable, "B-2 Sched Data", "B-2 Sched Data", False
DoCmd.TransferDatabase acImport, "Microsoft Access", "\\Szl-fs-02\509oss\OSW\mission tracking\wingsched.mdb", acTable, "Range Sched Data", "Range Sched Data", False
DoCmd.TransferDatabase acImport, "Microsoft Access", "\\Szl-fs-02\509oss\OSW\mission tracking\wingsched.mdb", acTable, "AR Sched Data", "AR Sched Data", False
End Sub
 

Unfortunatly you did not specify what version of Access you are using, but I believe this will work.

Look at Database password here... Access

I trust this will help.


[thumbsup2]

 
I am using access 2003, would I just replace the Opendatabase code with transferdatabase?

Set oAcc = New Access.Application
Set db = oAcc.DBEngine.OpenDatabase(TMP, _
False, False, ";PWD=doooo")
 

Try opening database first!!

Code:
'sDB should contain your MDB
Dim sPassword AS string 'Holds password

Set dbData = DBEngine.Workspaces(0).OpenDatabase(sDB, False, False, ";PWD=" & sPassword)

' Your code...
DoCmd.TransferDatabase acImport, "Microsoft Access", "\\Szl-fs-02\509oss\OSW\mission tracking\wingsched.mdb", acTable, "B-2 Sched Data", "B-2 Sched Data", False

'Then close the database.....



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top