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

    Alternative to Call Shell() ? (2000)

    In preparation for Access 2003, I'm trying to find "unsafe expressions". What's the alternative for the Shell function?

    I use it to open other Access db's from another Access db. I use the command button wizard to build the code.

    Dim stAppName As String

    stAppName = "C:Program FilesMicrosoft OfficeOfficemsaccess.exe 'H:Active_ProjectsGISEasements.mdb'"
    Call Shell(stAppName, 1)


    Sarah

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

    Re: Alternative to Call Shell() ? (2000)

    VBA code is not the same as an expression, so I don't know if Shell is blocked in VBA code.

    Alternatively, you can use ShellExecute. The following declaration should be at the top of a module, after Option Explicit and Option Compare Database, but before all procedures and functions:

    Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
    (ByVal hwnd As Long, _
    ByVal lpOperation As String, _
    ByVal lpFile As String, _
    ByVal lpParameters As String, _
    ByVal lpDirectory As String, _
    ByVal nShowCmd As Long) As Long

    Public Const SW_SHOWMAXIMIZED As Long = 3

    Use it like this:

    Dim lngResult As Long

    lngResult = ShellExecute(hWndAccessApp, "Open", "C:AccessTest.mdb", 0&, 0&, SW_SHOWMAXIMIZED)
    If lngResult <= 32 Then
    MsgBox "Couldn't open database.", vbExclamation
    End If

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

    Re: Alternative to Call Shell() ? (2000)

    The MS KB article is 294698.

    The section referring to JET 4.0 SP 7 and later says: "The following Visual Basic for Application functions will cause an error when the functions are called from and expression in a Jet query or from an Access property."

    Then a grid of functions are listed.

    So if I change enable Sandbox mode for Access applications (I have Jet SP8 installed), those listed functions can't be used in queries or Access properties (like in forms or reports?), right?

    I can't find anything that says it can't be done in code. So I guess that's right. Does anyone have other thoughts about this? Has anyone used Sandbox mode in Access 2000 or Access 2003?

    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
  •