Results 1 to 6 of 6
  1. #1
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    North Dakota, USA
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Shell function / RunApp action w/ spaces in path? (2000)

    I want to open a different database from with in a database when I click a button. I've tried using both the Shell function and the RunApp action in a macro. I get the same problem using both. "Access can't find the database file..." The path to the database contains spaces and I think that's the problem? How do I resolve this?

    For example.

    msaccess.exe C:Program FilesAccess databasesdb1.mdb

    Sarah

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Shell function / RunApp action w/ spaces in path? (2000)

    Is there some reason you're trying to do it this way instead of using the OpenCurrentDatabase method?
    Charlotte

  3. #3
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    North Dakota, USA
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Shell function / RunApp action w/ spaces in path? (2000)

    I wasn't aware that was method was available. I inherited a database and that's the method they used so that's why I questioned it. From what I read in the help the code would go something like this?

    Dim dbpath As String
    dbpath = "Crogram filesaccess database"

    Dim dbname As String
    dbname = dbpath & "db1.mdb"

    Dim app As Object
    Set app = CreateObject("Access.Application.9")

    app.OpenCurrentDatabase dbname

    Does that look right?

  4. #4
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    North Dakota, USA
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Shell function / RunApp action w/ spaces in path? (2000)

    Okay, something is not working.

    The msaccess.exe process opens but the form doesn't open, nothing opens on the screen. I added app.docmd.openform "switchboard" to the code to specify which form to open but that didn't work either.

    I moved the declaration of the access application to the module level. dim app as access. application - still didnt' work .

    sarah

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Shell function / RunApp action w/ spaces in path? (2000)

    Charlotte probably assumed that you wanted to open another database in the current instance of Access.
    To open a database in a new instance, you can use several methods:<pre>Shell """C:Program filesMicrosoft OfficeOfficeMsAccess.exe"" _
    ""C:Program FilesAccess databasesdb1.mdb"""</pre>

    Note the use of double double quotes within the string.
    Another method is

    Application.FollowHyperlink "C:Program FilesAccess databasesdb1.mdb"

    A third method is ShellExecute (the younger cousin of Shell). You'll find an example in <post#=191458>post 191458</post#>.

  6. #6
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    North Dakota, USA
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Shell function / RunApp action w/ spaces in path? (2000)

    The application.followhyperlink worked fine.

    Although it caused the startup form not to be centered. But that's not a big issue.

    Thanks for the help.
    Sarah

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •