Full Version: Call a function across a workspace - possible?
UtterAccess Forums > Microsoft® Access > Access Forms
wordstar
In a module in accdb #1 (currentdb, currentcodeproject), I created a workspace and populated it with 2 other accdb files. I an able to access tables throughout the workspace. I am not able to call a sub or function outside of currentdb, nor do intrinsic functions like dsum() work on the 'outside' data.
Is it possible to evaluate a function that in located in one of the accdb's in the workspace?
How would one refer to a workspace sub or function not in the currentdb?
wordstar
Additional info: The following code, which is independent of the workspace structure, allowed me to run a sub in an external accdb:
onst DBFilePath "c:/Another.accdb" 'Already is a member of workspace "wrk"
Const Subr = "RunThis"
Dim db As Database
Dim ap As Access.Application
Set ap = CreateObject("access.application")
ap.OpenCurrentDatabase DBFilePath
ap.Run Subr
...
It seems like a lot of code that ought to be doable within the workspace, but clearly I do not fully understand how the Access Data/Code model works. Also, ap.run does not work to fetch the calculated value from a function in Another.accdb, which I also want to be able to do.
Thanks for listening
Leonard
datAdrenaline
Click Here for a thread that may help you out...
On addition ... you can get a return value from ap.Run
x = ap.Run(strFunctionAsString, param1, param2, .... param30)
Example ...
x = ap.Run("GetMyValue", "SomeStringParameter")
...
You can also use the Eval() function (I seem to use Eval more than app.Run ....)
x = ap.Eval(strFullFunctionCallAsString)
Example ....
x = ap.Eval("GetMyValue('SomeStringParameter')")
Remember since you pass a string to the Eval() function the looks like the function call, you have a ton of flexibility ...
CODE
x = ap.Eval("GetMyValue('" & strMyLOCALVariable & "')")

HTH ...
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.