Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro within Code.. Waiting until Complete

Status
Not open for further replies.

kennedymr2

Programmer
May 23, 2001
594
AU
I have a sub routine written, which carries out several processes, and then runs a macro, then carries
on with more code.

ie.


vb code..........

Close #1
Close #2
DoCmd.RunMacro "macro1"
DoCmd.Hourglass False

Me.Progress = "Stage 2"
etc...
---------------------------------

Macro1 takes about 1 minute to do its thing!!

Stage 2 needs the info from the macro1.
Is there a way of putting the macro1 into action, but Stage 2 not starting until the macro1 is complete???
Without the operator having to hit any keys.
 
kennedymr2,

I may not be understanding your question correctly so please clear up the following:

A.) This code does not wait until macro1 is done running before executing "Stage 2"? That's not what I thought would happen.

B.) Can't you convert the macro to vb code? I would think "Stage 2" would wait for vb code to finish executing before it could launch itself.
 
Thanks for your advice.
I will write the function of the macro in vb code.
I was trying to avoid this, as the macro is a text import, and is a little complicated. The save specification of the macro, did all the hard work for me!!

I was hoping the would be a RESUME or some type of function that would put code in temporary hold while maco was running

Regards
 
You could try this but it's kind of silly:

Add something to the end of the macro1 to let you know that's done. e.g. have it update a temp table (temptable!counter) with the old counter number + 1.

Add a Loop statement that says:

Do While temptable!counter = old counter number +1
Stage2

Loop Until temptable!timedate = old counter number +1

 
Thanks everyone for your help.
I have looked closer at the vb text import, and now realize i can put the specification in the command line.
Will use VBA code , rater than Macro.

Thanks again
 
Hello everyone,

I was just wondering whether rewriting the text import worked?

You see, I have an import spec that doesn't work when run from inside VBA. I does work if I run it as a macro.

Weird eh?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top