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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Go to start of module 1

Status
Not open for further replies.

TimTDP

Technical User
Feb 15, 2004
373
ZA
In Access 2000 I have a function. When the code is running and a particullar criterea is met I need to restart the code from the beginning
How do I do this?
 
As in Do While True?
Code:
Do while True
    'Stuff
  If Thing = Something
    Exit Do
  End If
Loop

 
Go To XXY

On Error Resume XXX
(With a contional to Raise Err)

Recursion

are a few other possabilities



MichaelRed


 
or, if it is truly from the start of the code,
you could recall the code,

Sub TimeCalc()
y = 12
Docmd.SendObject acReport.....

Do While x <> y
x = x + mintNumber
Loop

If x = y Then Call TimeCalc Else Exit Sub
End Sub

...the code makes no sense, but I have seen before,
a call to a sub, within the sub itself.
 
Calling a sub, or function from within itself is called "recursion" and is very powerful, but can be very disastrous too, if used incorrectly.

Of course, there is always the GoTo statement to take you right back to the start of your code.
 
Thank-you VR,
I'm showing my ignorance here, it appears
M. Red, already brought up "recursion".

...if I only had my dictionary at the time!


...and yes, I was aware of the infinite iterations,
or multi-processing that could occur ,
(I guess as with any looping).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top