Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Mar 2003
    Location
    London, Gtr London
    Posts
    131
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Opening another Dbase (2002)

    Please could somebody help me with this line of code. For some reason it doesn't like the spaces between 'My' and 'Documents' and 'Koivision' and 'Database' :

    Private Sub cmdNewCust_Click()
    Shell "C:Program FilesMicrosoft OfficeXPOffice10MSACCESS.EXE c:My DocumentsKoivision DatabaseKoivision.mdb", vbNormalFocus
    End Sub

    What am I doing wrong?

    Many thanks
    Hayden

  2. #2
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Opening another Dbase (2002)

    As with desktop shortcut, when using Shell function you have to delimit any path or other command-line argument with spaces in it with double-quotes so it'll be evaluated as a single command or argument. Otherwise function will be evaluating C:Program, FilesMicrosoft, and OfficeOffice10MSACCESS.EXE, etc as separate command-line arguments.

    Recommend use syntax like this example:

    Shell Chr(34) & "C:Program FilesMicrosoft OfficeOffice10MSACCESS.EXE" & Chr(34) & " " & Chr(34) & "Cocuments and SettingsMARK DMy DocumentsNWTest.mdb" & Chr(34), vbNormalFocus

    Note use of Chr(34) to return double-quotes as delimiters. Example above worked correctly on my system.

    HTH

  3. #3
    2 Star Lounger
    Join Date
    Mar 2003
    Location
    London, Gtr London
    Posts
    131
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening another Dbase (2002)

    Thanks for the help Mark

    I understand what you are saying but I'm still getting a compile error. I've probably got the spaces wrong, but I just can't see where.

    Would you mind checking my code?

    Shell " & "C:Program FilesMicrosoft OfficeXPOffice10MSACCESS.EXE" & " & "" & " & "C:My DocumentsKoivision DatabaseKoivision.mdb" & ", vbNormalFocus

    Regards
    Hayden

  4. #4
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Opening another Dbase (2002)

    I don't see where you are using Chr(34) to insert double-quotes as argument delimiters. Here is another example that opens Northwind.mdb from default location in AXP:

    Public Sub TestShellFunction()

    Dim dblRtn As Double
    Dim strPath As String

    strPath = Chr(34) & "C:Program FilesMicrosoft OfficeOffice10MSACCESS.EXE" & Chr(34) & " " & _
    Chr(34) & "C:Program FilesMicrosoft OfficeOffice10SamplesNorthwind.MDB" & Chr(34)
    dblRtn = Shell(strPath, vbNormalFocus)

    End Sub

    In your example I would use this:

    Shell Chr(34) & "C:Program FilesMicrosoft OfficeXPOffice10MSACCESS.EXE" & Chr(34) & " " & _
    Chr(34) & "C:My DocumentsKoivision DatabaseKoivision.mdb" & Chr(34), vbNormalFocus

    The Chr function is needed to add double-quote character (Asc 34) into string being passed to Shell function.

    HTH

  5. #5
    2 Star Lounger
    Join Date
    Mar 2003
    Location
    London, Gtr London
    Posts
    131
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening another Dbase (2002)

    I totally misunderstood the relevance of the CHR(34), I thought I had to substitute the CHR(34) with the ' " ' character.

    Thanks very much for the help

    Kind Regards
    Hayden

Posting Permissions

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