Yes, you need to make sure that the code is getting triggered and run in all instances that you want it to. This is usually done by putting the code in one of the events. If you view the Properties of your form, go to the Events tab to see all the possibilities, and click on the Code Builder of a particular event to enter your code.
If you need help, please explain the circumstances in which you want the code to run. Like I said, the most common events I use are "On Open", "On Load", and "On Current".