Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.
Use an If statement around the code. Then you can use a variable to determine whether to run the event's code or not. Draw Event code is the exception, as that won't be run if the object isn't set to Visible.