We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

Get pass a password-Excel to Access

ca1358
ca1358 asked
on
Medium Priority
200 Views
Last Modified: 2010-04-07
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!



Comment
Watch Question

Infotrakker Software
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014
Commented:
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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Commented:
listen

Author

Commented:
still trying to figure this out!!

Author

Commented:
Got this work, thank you all for your help!!
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.