Is there another explanation for the error "For Loop Not Initialized" other than :
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.
- 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.
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.