Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2005
    Washington, DC

    Unanswered: Return value from another MDB

    Is there a way to run a function and return a value from another MDB:
    set app = new Application
    app.OpenCurrentDb strPath
    app.Run(strFunctionName, strParm1,...) 'where is return value please?



  2. #2
    Join Date
    Nov 2003
    You've got the bulk of it...if you want the return value from your function then simply do this:
    Dim app As New Access.Application
    Dim Result As Variant
    app.OpenCurrentDatabase (strPath)
    Result = app.Run(strFunctionName, strParm1,...)
    MsgBox Result

    Here is a funtion I created some time ago to carry out this task:
    Public Function CallRemoteAccessFunction(DB_Path As String, Function_Name As String, _
    				Optional Param1 As Variant, Optional Param2 As Variant, _
    				Optional Param3 As Variant, Optional Param4 As Variant, _
    				Optional Param5 As Variant, Optional Param6 As Variant, _
    				Optional Param7 As Variant, Optional Param8 As Variant) As Variant
       ' This Function will run a function within another Access Database
       ' and return the value of that remote function. The Remote function
       ' MUST be contained within a Database Module and be declared as
       ' Public.
       ' The DB_Path parameter MUST contain the FULL Path
       ' and mdb File Name.
       ' If a Parameters are required for the Remote Function then
       ' they can be supplied within the optional Param# parameters.
       ' If more than 8 parameters will be needed then modify this
       ' code to accomodate
       Dim appAccess As New Access.Application
       Dim TempArray() As String
       Dim ProjName As String
       TempArray() = Split(DB_Path, "\", -1, 1)
       ProjName = TempArray(UBound(TempArray))
       ProjName = Left$(ProjName, InStr(ProjName, ".") - 1)
       appAccess.OpenCurrentDatabase (DB_Path)
       CallRemoteAccessFunction = appAccess.Run(ProjName & "." & Function_Name, Param1, Param2, Param3, _
    							 Param4, Param5, Param6, Param7, Param8)
       Set appAccess = Nothing
    End Function

    Last edited by CyberLynx; 11-17-05 at 04:16.
    Self Taught In ALL Environments.....And It Shows!

  3. #3
    Join Date
    Nov 2005
    Washington, DC
    Thanks CyberLynx.
    I should have guessed myself but I didn't.
    Now I successfully pass Err object to calling procedure that informs the user if there is something wrong.

Posting Permissions

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