Error 506 - Declaration must precede statements

Declaration must precede statements - You attempted to use a declaration, such as a #DIM ALL metastatement after executable code. Move the declaration to a position before any statements that generate executable code.