You've got it backwards in setting those variables then setting them to the control IDs, and setting states on controls before you create them. Create the control, then set it's state. I also had to provide some undeclared variables: