I have a dynamic query builder designed in MS Access set up with a main Form for the user. I have noticed that if the user clicks away from the query window after it has run, it becomes 'hidden' behind the form and the user can not close it without going into the back end of the db. I have a refresh button which closes the form then immediately reopens it and a view query button which runs and opens the query as defined by the user. For both buttons, I want them to check to see if the query is open and if it is close it before doing anything else.
How can this be done?