Hi all!
I have a form that pulls in data from the current drawing (from block attributes) and fills combo boxes and textboxes with the data upon form load. We will call this "existing data".
The user is then allowed to change the data in the form and apply the changes (by clicking a button) so the attributes are updated in the drawing with the data the user entered. We will call this "new data".
Here is the problem. When the routine is run a second time, the form loads with the "existing data" that it originally loaded with even though the user has entered "new data". As if the form load functions are not firing.
My question is... how do I completely unload the form so that it is forced to load every time the routine is run. As it is now, it seems like it is being kept in memory and retains the original existing data rather than pulling in the new data.
The only way I have been able to get it to work is to close the drawing, reopen the drawing and run load the routine again using netload. This is NOT desirable!
Thanks for any advice in advance!
Solved! Go to Solution.
Solved by chiefbraincloud. Go to Solution.
By the way... I have tried using the dispose method, but it keeps me from re-loading the form a second time in the same drawing file. Even using the netload command again to load the routine will not let the form load a second time. Using dispose, I still have to close the drawing, reopen it, run netload to load the routine and then it works.
Seems like I am missing something.
The load event only fires once for each instance of a form, no matter how many times it may be shown and hidden.
So, Option one is to put your Load code into a seperate funtion that you call each time you show the form.
Otion two is to dispose the form, and recreate it as a new intance each time.
this will work fine, as it creates and destroys a new instance of the form each time:
For I = 0 to 100
dim myFrm as New Form1
Application.ShowModalDialog(myFrm)
myFrm.Dispose
Next I
This will not, because it tries to reuse the myFrm instance after it has been disposed:
dim myFrm as New Form1
For I = 0 to 100
Application.ShowModalDialog(myFrm)
myFrm.Dispose
Next I