So, I had this bright idea today that didn't quite work out. Or maybe it is working out but requires me to change a habit. I'm working on a form that will be a sub-form of another form. During initial development, I find it easier or better to work on the form as stand-alone entity rather than a sub-form. One reason is that I can edit the form using the entire screen instead of just that portion of the main form allocated to the sub-form.
Anyway, this sub-form references some objects on the parent form. Those same named objects exist on the sub-form, so I thought why don't I do this:
and then replace this
Then, when I am ready to put the two forms together, all I have to do is change
Voila, all good, right? Well, the weirdest thing happened. Suddenly, I got compile errors in both the main form and sub-form. The compiler was telling me that object names didn't exist that I knew darn well existed. I have been running the main form for several days.
I tried this experiment. I changed an object name from "Salesman_filte r" to "Tsalesman_filt er", and I changed my code from Me.Salesman_fil ter to Me.Tsalesman_fi lter, and then the compiler was happy. The compile error was now reported a few lines further down on a reference to another object. I changed Tsalesman_filte r back to Salesman_filter and the compiler was still happy with the Me. reference, but still unhappy with the following reference to a different object.
So very weird. Then I tried changing the Me. references to Me! references, and the compiler stopped seeing an error. I changed all my Me. references to Me! references and no more errors.
What in the world happened? Can any of you explain this?
Thanks!
Anyway, this sub-form references some objects on the parent form. Those same named objects exist on the sub-form, so I thought why don't I do this:
Code:
dim obj as object set obj = Me
Code:
me.parent.controlname ... to obj.controlname
Code:
set obj = me to set obj = me.parent
I tried this experiment. I changed an object name from "Salesman_filte r" to "Tsalesman_filt er", and I changed my code from Me.Salesman_fil ter to Me.Tsalesman_fi lter, and then the compiler was happy. The compile error was now reported a few lines further down on a reference to another object. I changed Tsalesman_filte r back to Salesman_filter and the compiler was still happy with the Me. reference, but still unhappy with the following reference to a different object.
So very weird. Then I tried changing the Me. references to Me! references, and the compiler stopped seeing an error. I changed all my Me. references to Me! references and no more errors.
What in the world happened? Can any of you explain this?
Thanks!
Comment