Copy Table to Another Database (VBA)-- What if the another Database has a password? How can I include the password?

JohneX

New Member
Joined
Oct 26, 2020
Messages
7
Office Version
  1. 2013
Platform
  1. Windows
  2. Web
This Code is from Mr. Boblarson:

Dim objAcc as Object
Dim objAcc2 As Object

Set objAcc = New Access.Application
objAcc.OpenCurrentDatabase("C:\FilePathandNameHere.accdb")


objAcc.DoCmd.CopyObject "D:\AnotherFilePathAndNameHere.accdb", , acTable,"SourceTableNameHere"

objAcc.CloseCurrentDatabase

Set objAcc = Nothing
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
I've never used that method but from what I know of it, it opens the db in the Access application window and then it becomes the active database, in which case I don't see how that will work. The method is meant for opening a db from another COM application, such as Excel. M$ even mentions closing the current db window before doing this. Perhaps from the db that contains the table
SQL:
SELECT * INTO Table1 IN '' [MS Access;PWD=PasswordHere;DATABASE=C:\....\dbNameHere.mdb]
FROM Table2
or
SQL:
SELECT * INTO [";PWD=PasswordHere;DATABASE=C:\....\dbNameHere.mdb"].table1 FROM table2
 
Last edited:
Upvote 0
You're welcome. Care to let us know what worked?
 
Upvote 0
thread_01.png
 
Upvote 0

Forum statistics

Threads
1,221,531
Messages
6,160,354
Members
451,640
Latest member
idavies1402

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top