[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 311
  • Last Modified:

microsoft access 2007 wait for a module to finish before starting another module

I have about 22 modules, that need to run in order.  The results of each module is dependent on the previous module.  I need to ensure that the module has run and finished without errors before starting the next one.  I have created a module called "Testing" where I am calling my other modules "Call calculate_line1", line2, line 3 etc. all the way to line 26.  I just need to make sure that line1 has finished processing before line2 etc. and I need to automate.
1 Solution
That is the way the code runs, the first line will be executed before the next. If the code can encounter an error (which I'm sure it can) you should use error handling in each sub-routine.
Jeffrey CoachmanCommented:
Also, FWIW,

The code for a lot of these modules is basically the same...
Ultimately, you should try to consolidate one module to work for multiple functions

Just FYI

When you say modules, do you really mean the procedures inside a module?  There are 2 kinds of procedures; Subs (a.k.a subroutines) and Functions.  

With 22 of these it sounds like you need to revisit your process.  A single loop routine may probably work in its place.  Perhaps you can post some of your code and we can help you there.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
In addition to what the other Experts have posted, the way I normally execute procedural code is by using Functions, and having each Function return a response code (usually just True or False). I check that return code before running the next routine, which insures that RoutineA completes before RoutineB. For example:

Dim fOK As Boolean

fOK = MyFirstProcedure

If fOK Then
  fOK = MySecondProcedure
End If

If fOK Then
  fOK = MyThirdProcedure
End If

Your various procedures would then return a True or False, and your code could take action based on each. For example, I often log actions at the end of a process, which is not a required process - so my action there may be simply to alert someone, or just ignore it depending on the sort of impact I think it may have.

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now