Hi,
Can some one please help
I have a for Loop
For howmany = 1 to endofline
docmd.openform
do some work
next
I need the loop to wait for user to finish enterning data into the form that
was opened by the loop, before continuing to the next loop
I have tried using a timmer but it did not work well
any advice
Thanks
Dib
I suggest taking this code to a standard module instead of in a form module. Don't have the code running when it doesn't need
to be. It may look like this when you're done.
Public Sub MyLoop(Optional SetStart As Long)
Static MyCount As Long
' have all of your other variables set to Static so that they hang around while waiting to be called again
' since you said to start from 1 and variables are initialized as 0
If MyCount = 0 Then MyCount = 1
' if we want to start over again, just tell MyLoop to start from 1 again
If Not IsMissing(SetStart) Then MyCount = SetStart
If MyCount > [endofline] Then Exit Sub
' your main loop code here
MyCount = MyCount + 1
End Sub
Then on the event of a form entry completed, using the AfterUpdate event, just simply call the MyLoop sub again and it will
continue the process as needed. Have the entry form which you open be modal (means it locks the focus on itself while it's
open, option found in the "Other" properties) so that the user can't start the process over again accidentally.
Of course you can change the code however you desire, this is just to give you an idea of a better way to do it. Whenever you
might need to run the loop again just have the form you open on it's Close or AfterUpdate event (or whatever else you desire)
call this sub again to run through once more.
Jeremiah Ellison
Ellison Enterprises - Your One Stop IT Experts