Return info from child form

G

Guest

Outlook 2003
Exchange 2003

My custom form (the "parent") has a custom action that launches another
custom form (the "child") based on IPM.Note. I want to return certain
information (e.g. the list of recipients) from the child form to the parent
form when the child is sent. I guess the child form would need to be modal,
but I'm not sure if this is possible with an Outlook form.

First, then, is this possible?

Then, can anyone give me any advice on how to achieve it?

Many thanks in advance

Vaughan
 
G

Guest

OK, I've dug around the net and ...

1) I have found out how to launch my child form "modally"
using NewItem.Display(True);

2) I have managed to make the parent form code resume
execution after the modal child form is closed;

But so far I haven't been able to return any information
from the child form. Basically, once the form is sent, the object
seems to be wiped from the parent form's "consciousness", so
that constructions like "NewItem.Property" just return null values.

Can anyone make any suggestion here? I would be extremely grateful for any
pointers.

Thanks

Vaughan
 
S

Sue Mosher [MVP-Outlook]

Put code in the child item's form to set properties in the parent item.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
H

Hollis D. Paul

Sue Mosher said:
Put code in the child item's form to set properties in the parent item.
More specifically, pass the parent's storeID, and the ItemID, and you
will be able to bring up the parent item in the namespace of the child
item, using code.

You can create the child item in code, retaining the object pointer and
stuff info into the child item after it is created, and retrieve
properties from the child item, as long as the child item has not been
closed. It might be reasonable for you to do this with something you are
going to use, but I would not give it to anyone else and expect them to
remember the nitty-gritty details of doing it safely. You are really
better off keeping the parent and child items as independent items, and
let code in the child item push data to the parent item.

Hollis D. Paul [MVP - Outlook]
(e-mail address removed)
Mukilteo, WA USA
 
G

Guest

Thanks for this advice Hollis.

I did what you said, and I can now pass information back as wanted. The
problem is now with getting things to happen safely in the right order. If I
allow the child form to open modelessly, then changes can be made to the
parent while it is waiting for the child to return its data, and this can
cause problems, but if I open it modally, I now see that the Item_Open code
doesn't fire until after it is closed (!), so several key initialisation
routines don't run before I start to use the form.

So:

1) Can the child form's Item_Open event be forced to run
when the form is opened modally?

.... and if not :

2) Is there some other event that would fire when the child
form is opened modally?

.... or :

3) Can I protect the integrity of the parent form by making it
inaccessible in some other way while the child form is open?

I really hope you can help. Thanks again.

Vaughan


Hollis D. Paul said:
Sue Mosher said:
Put code in the child item's form to set properties in the parent item.
More specifically, pass the parent's storeID, and the ItemID, and you
will be able to bring up the parent item in the namespace of the child
item, using code.

You can create the child item in code, retaining the object pointer and
stuff info into the child item after it is created, and retrieve
properties from the child item, as long as the child item has not been
closed. It might be reasonable for you to do this with something you are
going to use, but I would not give it to anyone else and expect them to
remember the nitty-gritty details of doing it safely. You are really
better off keeping the parent and child items as independent items, and
let code in the child item push data to the parent item.

Hollis D. Paul [MVP - Outlook]
(e-mail address removed)
Mukilteo, WA USA
 
H

Hollis D. Paul

So:

1) Can the child form's Item_Open event be forced to run
when the form is opened modally?

.... and if not :

2) Is there some other event that would fire when the child
form is opened modally?

.... or :

3) Can I protect the integrity of the parent form by making it
inaccessible in some other way while the child form is open?

I really hope you can help. Thanks again.
You have gone as far as I have ever gone. About the only thing I can suggest
is to use code to hide the parent form when you fire up the child. Then, when
you are done with data entry in the child and have pushed data back to it,
unhide the parent. Never tried it, but it might work.

Hollis D. Paul [MVP - Outlook]
(e-mail address removed)
Mukilteo, WA USA
 
W

Wolfram Jahn

Vaughan said:
1) Can the child form's Item_Open event be forced to run
when the form is opened modally?

Dont know, but:
... and if not :

2) Is there some other event that would fire when the child
form is opened modally?

If I remember it correctly you can define and then call custom actions
from outside.
... or :

3) Can I protect the integrity of the parent form by making it
inaccessible in some other way while the child form is open?

You could switch to some unused (and unusable:) modified form page
containing not much more than a label which says "I'm in use now".

Wolfram
 
G

Guest

Hollis and Wolfram

Thank you both for your help with this.

I experimented with the various options and in the end (for now at least)
have settled for displaying the child form modally. I included code in the
parent to initialise the child form and the results so far seem to be OK.

Once again, thanks very much

Vaughan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top