how can i delete with vba on access 2013 delete a table on another access database that closed with a password (i know the password)

hi

i there some option with vba on access form to delete a table on another database that is closed with this password "TEST"

thanks
bill201Asked:
Who is Participating?
 
OnisanCoder / ProgrammerCommented:
Sub DeleteTable()

'Three constants you need to change to make it work!
Const remoteDatabase As String = "C:\MyDB.accdb"
Const PW             As String = "TEST"
Const Tablename      As String = "MyTableName"

Dim ws As DAO.Workspace
Dim db As DAO.Database
   
    Set ws = DBEngine.Workspaces(0)
   
        Set db = ws.OpenDatabase(remoteDatabase, False, False, "MS Access;PWD=" & PW)
   
            'Delete the table
            db.Execute "DROP TABLE [" & Tablename & "]", dbFailOnError
       
        Set db = Nothing
    Set ws = Nothing
End Sub
0
 
bill201Author Commented:
thanks a lot
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.