Results 1 to 4 of 4
  1. #1
    Rick West is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2009
    Posts
    90

    Open a second db from a cmd button

    I tried using the Wizard to create the code behind a cmd button to do this; here is the code:



    Private Sub cmdPNG1_Click()
    On Error GoTo Err_cmdPNG1_Click
    Dim stAppName As String
    stAppName = "W:\MARKETNG\RICKWEST\PNG.mdb"
    Call Shell(stAppName, 1)
    Exit_cmdPNG1_Click:
    Exit Sub
    Err_cmdPNG1_Click:
    MsgBox Err.Description
    Resume Exit_cmdPNG1_Click

    End Sub

    But I get "Invalid procedure or call argument" - any hints as to what I should try next?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    I believe Shell requires the executable path as well as the database path. Check it out in VBA help. I would probably use FollowHyperlink instead, which doesn't.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    Private Sub Command2_Click()
    On Error GoTo Err_Command2_Click
    Dim strfilePath As String
    strfilePath = "C:\Sample3.mdb"
    Application.FollowHyperlink strfilePath, , True

    Exit_Command2_Click:
    Exit Sub

    Err_Command2_Click:
    MsgBox Err.Description
    Resume Exit_Command2_Click

    End Sub

    I think this is What Sir Paul is indicating to.

  4. #4
    Rick West is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2009
    Posts
    90

    Hyperlink

    I forgot about using a Hyperlink - tried it, it worked, thanks guys.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 03-03-2010, 07:29 PM
  2. Replies: 2
    Last Post: 02-26-2010, 08:14 AM
  3. Replies: 3
    Last Post: 01-14-2010, 08:32 AM
  4. Replies: 3
    Last Post: 10-16-2009, 07:54 AM
  5. Open a linked subform with a command button
    By flablueeyedblond in forum Forms
    Replies: 0
    Last Post: 11-18-2005, 01:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums