Your pMain variable is not defined in the procedure you're calling it in. Its a local variable for ColorChanger