On one of the forms I have a button cmdMainMenu. On its click either of the two things should happen which are shown below. But I use a global variable isForm1Hidden . Now this is the problem I can imagine that I will have to hide form1 at so many places in future and then I will have to set "isForm1Hidden" at those places. Similarly when I will bring up the form again I will have to set it again.
This is a major problem , if I forget this somewher I will run into some other problems. How can I avoid this ?
I am working on an old code with a very poor design and it has so many global variables for cases like this. I will appreciate if someone can help me with this
Private Sub cmdMainMenu_Click()
If isForm1Hidden Then
strBuildSQL = SelectQueryBuilder("Build_Number", "LU_Build")
Set oBuildRS = ExecuteQuery(strBuildSQL)
Call GeneralCodes.PopulateComboBox(Form1.cboBuild, oBuildRS, "Build_Number")
isForm1Hidden = False
errorinForm1 = False