> Two issues: first, CallByName is slow as hell. Second, it's bad programming
> practice: a called object shouldn't need any knowledge of its caller.
[quoted text clipped - 50 lines]
> >
> > Jerry Bodoff
> As far as I know Userform1 cannot read Userform2
> properties since return to Userform1 is not made until Userform2 unloads.
The process is more subtle than this. It is sufficient for UserForm2 to be
hidden to pass control back to UserForm1. That too is better programming
practice: in classic object-oriented design, an object should never
terminate itself -- that's the responsibility of the caller.
Experiment with code along these lines --
In UserForm1 ------
Dim pForm as UserForm2
Set pForm = new UserForm2
.... at this point you can set and read properties in pForm
pForm.Show
... at this point also you can set and read properties in pForm
unload pForm
Set pForm = nothing
In UserForm2 ----
Sub cmdClose_Click()
Me.Hide
End Sub
> Hi Jezebel,
>
[quoted text clipped - 87 lines]
>> >
>> > Jerry Bodoff
JBNewsGroup - 19 Aug 2005 15:24 GMT
Hi Jezebel,
I took an approach similar to API's and dialogs. I created a "Dialog
Structure" module which contains the structure Type definition and a Public
definition. Form1 populates the structure by DlgData.Field and then shows
Form2. Form2 does its thing and populates applicable structure fields.
Form2, when done, "closes" itself and therefore Form1 is re-activated. A
proper approach would be to create a Class Module and set properties and let
the Class Module "read" and "write" structure data and start the form.
As far as I know hiding Form2 does not create a return to Form1. A return
is made when Form2 "shuts down". What you suggest is probably possible with
modeless forms. All my forms are modal.
Thanks for the help and discussion. It is always informative to see how
other people approach a problem and one always learns from these
discussions.
Jerry Bodoff
> > As far as I know Userform1 cannot read Userform2
> > properties since return to Userform1 is not made until Userform2 unloads.
[quoted text clipped - 117 lines]
> >> >
> >> > Jerry Bodoff
JBNewsGroup - 19 Aug 2005 16:24 GMT
Hi Jezebel,
I have to apologize. In my previous answer I was unaware that Hide
re-activated the calling form.
As I said we are always learning. To do things properly I am creating a
ClassModule to "read" and "write" the data structure.
Thanks.
Jerry Bodoff
> > As far as I know Userform1 cannot read Userform2
> > properties since return to Userform1 is not made until Userform2 unloads.
[quoted text clipped - 117 lines]
> >> >
> >> > Jerry Bodoff
Jezebel - 20 Aug 2005 00:09 GMT
Your class module approach is certainly thorough, but it seems excessive to
me. It's worth noting that a form module is just a special kind of class
module anyway. It has most of the properties and behaviours of an ordinary
class module, with the additional graphic component. If you never Show the
form, it behaves exactly like any other class module.
So rather than populating your class, it might be simpler just to add
property functions to the form itself. Occam's razor and all that.
> Hi Jezebel,
>
[quoted text clipped - 139 lines]
>> >> >
>> >> > Jerry Bodoff
JBNewsGroup - 20 Aug 2005 06:05 GMT
Hi Jezebel,
Thanks for all your help.
I decided to use the Class Module because I am doing a bit of data
validation in it and I have a few Custom Dialogs that will be processed by
the same module. They all use the same structure and I have about 10
forms that will call it.
Jerry Bodoff
> Your class module approach is certainly thorough, but it seems excessive to
> me. It's worth noting that a form module is just a special kind of class
[quoted text clipped - 148 lines]
> >> >> >
> >> >> > Jerry Bodoff