Connecting Tech Pros Worldwide Forums | Help | Site Map

Tech: How to return a value to an external call?

Paul Drabik
Guest
 
Posts: n/a
#1: Nov 12 '05
First time post here ... I have been researching and not found info on
this.

One user here described the succinct way to call MS-Access and kick
off a command:
=====
Dim app As Access.Application

Set app = GetObject(, "Access.Application.8")
If Err.Number = 429 Then
Set app = CreateObject("Access.Application.8")
End If

app.docmd.beep

Set app = Nothing
=====

This works fine and I will substitute the main command with:

app.docmd.runmacro("myMacro")

The macro calls a function in a module and then quits the app.

The question here is:
How can a numeric value be returned to the calling vb program?
Does the VB code wait for a return value at all or do we need to
perhaps write a TXT file to pass this to the calling program?

I guess we will see, but does the VB program still run while the
Access object is doing it's data processing? or does the VB need to
run in a loop, continuously checking for the result file?

Thanks in advance for any help.
- Paul
Tony Toews
Guest
 
Posts: n/a
#2: Nov 12 '05

re: Tech: How to return a value to an external call?


pdrabik@bigfoot.com (Paul Drabik) wrote:
[color=blue]
>How can a numeric value be returned to the calling vb program?
>Does the VB code wait for a return value at all[/color]

I don't ever recall seeing any way to set a return code for such a calling app.
Such may exist and I would welcome any such info.

Application.Quit exists but it has no return code. (At least not in A97) Neither
does DoCmd.Quit.
[color=blue]
>or do we need to
>perhaps write a TXT file to pass this to the calling program?[/color]

Likely your best option.
[color=blue]
>I guess we will see, but does the VB program still run while the
>Access object is doing it's data processing? or does the VB need to
>run in a loop, continuously checking for the result file?[/color]

Both well run. So yes VB will need to run in a loop.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Paul Drabik
Guest
 
Posts: n/a
#3: Nov 12 '05

re: Tech: How to return a value to an external call?


Thanks so much for confirming what I suspected.
Now I need to nail down how to kick off the macro of the needed MDB file.

I know I can app.DoCmd.RunMacro("mymacro")
But how do I address the MDB that contains the macro?

I will be researching further.
- Paul

Tony Toews <ttoews@telusplanet.net> wrote in message news:<u7uq80t2pgdh5v5obil9irfinqusnvm2ii@4ax.com>. ..[color=blue]
> pdrabik@bigfoot.com (Paul Drabik) wrote:
>[color=green]
> >How can a numeric value be returned to the calling vb program?
> >Does the VB code wait for a return value at all[/color]
>
> I don't ever recall seeing any way to set a return code for such a calling app.
> Such may exist and I would welcome any such info.
>
> Application.Quit exists but it has no return code. (At least not in A97) Neither
> does DoCmd.Quit.
>[color=green]
> >or do we need to
> >perhaps write a TXT file to pass this to the calling program?[/color]
>
> Likely your best option.
>[color=green]
> >I guess we will see, but does the VB program still run while the
> >Access object is doing it's data processing? or does the VB need to
> >run in a loop, continuously checking for the result file?[/color]
>
> Both well run. So yes VB will need to run in a loop.
>
> Tony[/color]
Tony Toews
Guest
 
Posts: n/a
#4: Nov 12 '05

re: Tech: How to return a value to an external call?


pdrabik@bigfoot.com (Paul Drabik) wrote:
[color=blue]
>Thanks so much for confirming what I suspected.
>Now I need to nail down how to kick off the macro of the needed MDB file.
>
>I know I can app.DoCmd.RunMacro("mymacro")
>But how do I address the MDB that contains the macro?[/color]

Searching brings me a screen "Startup command-line options"

/x macro Starts Microsoft Access and runs the specified macro. Another way to
run a macro when you open a database is to use an AutoExec macro.

But you will need to use the Shell command to start Access which allows you to
specify command lines. Unfortunately this also means you must explicitly state the
path and file name of the appropriate msaccess.exe file. This is a Windows
limitation.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Closed Thread


Similar Microsoft Access / VBA bytes