Link to home
Start Free TrialLog in
Avatar of Millkind
MillkindFlag for Afghanistan

asked on

Run Access Macro if DB has password

This one is going to be real simple. I have the following code which works great but prompts the user for the database password.  Is there a way to send the password with the database path so it won't prompt the user?

    Private Sub RunMacro(ByVal sMacro As String)
        Dim oAccess As Object

        oAccess = CreateObject("Access.Application")
        ' Open the database
        oAccess.OpenCurrentDatabase(dbpath)
        Try
            oAccess.DoCmd.RunMAcro(sMacro)
            oAccess.DoCmd.Maximize()
            oAccess.Visible = False
        Catch e As Exception
            MsgBox("Macro is cancelled or does not exist")
        Finally
            oAccess = Nothing
        End Try
    End Sub

ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial