[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 186
  • Last Modified:

Get pass a password-Excel to Access

I this code in excel, How do I get pass the "password".

At this point, click the command button and it open Access and bypass the password and go directly to a form.

'opens access
   
    Range("Q23").Select
   
   
    ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="Volume.mdb", _
        TextToDisplay:="Volume.mdb"
   
    Range("Q23").Select
   
    Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
    Set App = GetObject("\\Dtcnas-ilsp002\mandatory\Analysts - Working Files\Carol\Demo\Volume.mdb;pwd=OPPs;")
App.Application.DoCmd.RunMacro "Macro2CloseSwitchboard"
App.Application.DoCmd.openform "Form"


 Any help would greatly be appreciated!



0
ca1358
Asked:
ca1358
  • 2
1 Solution
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Generally you must pass the db password via  commandline switch. Perhaps this code snippet will help (came from here:  http://support.microsoft.com/?id=147816#E0GE0ADAAA)

This uses ULS, but you can alter the commandline switches to insert the db password. You may not need the /user switch either, so you may need to comment out that line.

   Option Explicit
   Dim objAccess as Object

   '----------------------------------------------------------------------
   'This procedure sets a module-level variable, objAccess, to refer to
   'an instance of Microsoft Access. The code first tries to use GetObject
   'to refer to an instance that might already be open. If an instance is
   'not already open, the Shell() function opens a new instance and
   'specifies the user and password, based on the arguments passed to the
   'procedure.
   '
   'Calling example: OpenSecured varUser:="Admin", varPw:=""
   '----------------------------------------------------------------------

   Sub OpenSecured(Optional varUser As Variant, Optional varPw As Variant)
      Dim cmd As String
      On Error Resume Next
      Set objAccess = GetObject(, "Access.Application")
      If Err <> 0 Then 'no instance of Access is open
        If IsMissing(varUser) Then varUser = "Admin"
        cmd = "C:\Program Files\Microsoft Office\Office\MSAccess.exe"
        cmd = cmd & " /nostartup /user " & varUser
        If Not IsMissing(varPw) Then cmd = cmd & " /pwd " & varPw
        Shell pathname:=cmd, windowstyle:=6
        Do 'Wait for shelled process to finish.
          Err = 0
          Set objAccess = GetObject(, "Access.Application")
        Loop While Err <> 0
      End If
   End Sub
0
 
JackOfPHCommented:
listen
0
 
ca1358Author Commented:
still trying to figure this out!!
0
 
ca1358Author Commented:
Got this work, thank you all for your help!!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now