Solved For Loop Not Initialized (1 Viewer)

Ummyeah

New member
Local time
Yesterday, 19:00
Joined
Jun 16, 2022
Messages
15
Is there another explanation for the error "For Loop Not Initialized" other than :
  • You jumped into the middle of a For...Next loop. Remove the jump into the loop. Placing labels inside a For...Next loop isn't recommended.
Every solution I have been able to find is that you have jumped into the loop with a GoTo or something. I am not doing that. I have two for loops in a module. Both iterate through their own array. The first one looks like this

For Each frmName In mainForms

'some code that works fine

Next frmName


the next for loop looks like this

For Each frmName in OpenForms

DoCmd.Close acForm, frmName

Next frmName

I tested it up to the second for look and it works great, and for some reason when it gets to the second loop I get the error "For Loop Not Initialized". I thought perhaps it was because I used the same iterator "frmName", but even if I change the variable to something else, I still get the same error. When I looked up the error, the only solution is in relation to jumping into the loop, but I assure you I am not doing that. The loop is inside an if statement that evaluated the result of a yes/no message box. I can add the entire code if necessary, but the rest of it works fine.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 18:00
Joined
Oct 29, 2018
Messages
21,494
nevermind i'll figure it out myself. thanks anyway.
Congratulations! Glad to hear you got it sorted out. You might consider posting the solution in case it helps others who could find themselves in the same situation in the future. Good luck with your project.
 

Users who are viewing this thread

Top Bottom