PC Review Forums Newsgroups Microsoft Outlook Microsoft Outlook Form Programming Form code events are not fired when editing an item based on the form

Reply

Form code events are not fired when editing an item based on the form

 
Thread Tools Rate Thread
Old 08-09-2004, 09:40 AM   #1
Pau Larsen
Guest
 
Posts: n/a
Default Form code events are not fired when editing an item based on the form


I have created a custom form in Outlook 2003 SP1. It has
a button with an onclick event.

When creating an item based on the form the buttons
onclick event is fired fine. When reopening the same item
the buttons onclick event is not fired???

I have had this problem on my machine for a month (since
I created the form). Today I was showing somebody the
problem and after moving security settings up and down (a
wild guess) it worked! Eventhough the security settings
ended up in the same place (highest security level). I
might have done something else in Outlook at the same
time without thinking about it. I can not reproduce the
problem on my machine now.

I then used the form on another computer and the problem
was there too. And the security trick does not work there.

Anybody have any idea why my onclick event on a button on
a custom form does not fire when editing an item based on
the form?

/Pau
  Reply With Quote
Old 08-09-2004, 01:04 PM   #2
Sue Mosher [MVP-Outlook]
Guest
 
Posts: n/a
Default Re: Form code events are not fired when editing an item based on the form

If the form runs code when you use Run This Form in design mode, but doesn't
run code after you have sent or saved an item using the form, you probably
have done something to "one-off" the form. Outlook 2003, Outlook 2002,
Outlook 2000 SP2 and Outlook 2000 or 98 with the Email Security Update will
not run code on one-off forms; see http://www.outlookcode.com/d/secforms.htm
for more information on this issue.

To ensure that a form does not one-off:

-- Make sure the "Send form definition with item" box on the (Properties)
tab of the form is *not* checked. [1]

-- For in-house corporate use with Exchange Server, publish the form to the
Organization Forms library or a public folder's forms library, as
appropriate for your application.

-- For collaboration via the Internet, publish your form to your Personal
Forms library. Save it as an .oft file and send it to other people who need
to use it with instructions to publish it with the same form name that you
used.

Many other things can cause one-off forms. If the above steps don't work on
a new item created with your form, see
http://www.slipstick.com/dev/formpub.htm#oneoff for other possible causes.

[1] Whenever you publish a message form, Outlook will suggest that you may
want to check the "Send form definition with item" box to ensure that the
recipient will have the form, especially if you're sending to someone via
the Internet. In the current Outlook security environment, this suggestion
is obsolete. Ignore it unless your form has no code behind it.


--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"Pau Larsen" <anonymous@discussions.microsoft.com> wrote in message
news:7ea401c4957f$89b5e140$a501280a@phx.gbl...
>I have created a custom form in Outlook 2003 SP1. It has
> a button with an onclick event.
>
> When creating an item based on the form the buttons
> onclick event is fired fine. When reopening the same item
> the buttons onclick event is not fired???
>
> I have had this problem on my machine for a month (since
> I created the form). Today I was showing somebody the
> problem and after moving security settings up and down (a
> wild guess) it worked! Eventhough the security settings
> ended up in the same place (highest security level). I
> might have done something else in Outlook at the same
> time without thinking about it. I can not reproduce the
> problem on my machine now.
>
> I then used the form on another computer and the problem
> was there too. And the security trick does not work there.
>
> Anybody have any idea why my onclick event on a button on
> a custom form does not fire when editing an item based on
> the form?
>
> /Pau



  Reply With Quote
Old 09-09-2004, 10:13 AM   #3
Pau Larsen
Guest
 
Posts: n/a
Default Re: Form code events are not fired when editing an item based on the form

Thanks for the a good answer. I have now done some
further investigation.

On both computers that I am testing my form on the
behavior is now like this:

When I create an item the script works. The first time I
edit the item the script works. The second time I edit
the item the script does not work and I can see that type
is set to the original "appoinment" and item size has
increased indicating that it is now a one-off. I assume
that it becomes a one-off when saving after the first
edit.

From the links provided and i stumbled over this line
from "http://support.microsoft.com/?kbid=290657":

"The following are known scenarios where items can be
unexpectedly one-offed.......You used Microsoft Visual
Basic Scripting Edition (VBScript) code in the custom
form and used some methods or commands that are causing
the item's form definition to change. The following
methods most commonly cause this
behavior:........PossibleValues"

I am setting the "PossibleValues" attribute in my code.
It is a core feature of my project to dynamically set
dropdown values based on web service calls.

At the end of the same support article I found a
workaround like this:

---------------------------------------
'Save the MessageClass property
sSaveMessageClass = Item.MessageClass

[my code including the use of "PossibleValues" runs here]

' Restore the MessageClass property
Item.MessageClass = sSaveMessageClass

' Save the changes to the form
Item.Save
---------------------------------------

It does not change the behavior as described earlier.

Can anyone suggest a next step for me now that my problem
has been more precisely described?

/Pau

>-----Original Message-----
>If the form runs code when you use Run This Form in

design mode, but doesn't
>run code after you have sent or saved an item using the

form, you probably
>have done something to "one-off" the form. Outlook 2003,

Outlook 2002,
>Outlook 2000 SP2 and Outlook 2000 or 98 with the Email

Security Update will
>not run code on one-off forms; see

http://www.outlookcode.com/d/secforms.htm
>for more information on this issue.
>
>To ensure that a form does not one-off:
>
>-- Make sure the "Send form definition with item" box on

the (Properties)
>tab of the form is *not* checked. [1]
>
>-- For in-house corporate use with Exchange Server,

publish the form to the
>Organization Forms library or a public folder's forms

library, as
>appropriate for your application.
>
>-- For collaboration via the Internet, publish your form

to your Personal
>Forms library. Save it as an .oft file and send it to

other people who need
>to use it with instructions to publish it with the same

form name that you
>used.
>
>Many other things can cause one-off forms. If the above

steps don't work on
>a new item created with your form, see
>http://www.slipstick.com/dev/formpub.htm#oneoff for

other possible causes.
>
>[1] Whenever you publish a message form, Outlook will

suggest that you may
>want to check the "Send form definition with item" box

to ensure that the
>recipient will have the form, especially if you're

sending to someone via
>the Internet. In the current Outlook security

environment, this suggestion
>is obsolete. Ignore it unless your form has no code

behind it.
>
>
>--
>Sue Mosher, Outlook MVP
>Author of
> Microsoft Outlook Programming - Jumpstart for
> Administrators, Power Users, and Developers
> http://www.outlookcode.com/jumpstart.aspx
>
>
>"Pau Larsen" <anonymous@discussions.microsoft.com> wrote

in message
>news:7ea401c4957f$89b5e140$a501280a@phx.gbl...
>>I have created a custom form in Outlook 2003 SP1. It has
>> a button with an onclick event.
>>
>> When creating an item based on the form the buttons
>> onclick event is fired fine. When reopening the same

item
>> the buttons onclick event is not fired???
>>
>> I have had this problem on my machine for a month

(since
>> I created the form). Today I was showing somebody the
>> problem and after moving security settings up and down

(a
>> wild guess) it worked! Eventhough the security settings
>> ended up in the same place (highest security level). I
>> might have done something else in Outlook at the same
>> time without thinking about it. I can not reproduce the
>> problem on my machine now.
>>
>> I then used the form on another computer and the

problem
>> was there too. And the security trick does not work

there.
>>
>> Anybody have any idea why my onclick event on a button

on
>> a custom form does not fire when editing an item based

on
>> the form?
>>
>> /Pau

>
>
>.
>

  Reply With Quote
Old 09-09-2004, 12:05 PM   #4
Sue Mosher [MVP-Outlook]
Guest
 
Posts: n/a
Default Re: Form code events are not fired when editing an item based on the form

The solution is simple: Don't use PossibleValues. Instead, populate the
combo box with AddItem, List or Column. See
http://www.outlookcode.com/d/formcontrols.htm#listcombo

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"Pau Larsen" <anonymous@discussions.microsoft.com> wrote in message
news:077a01c4964d$4c28d890$a401280a@phx.gbl...
>
> When I create an item the script works. The first time I
> edit the item the script works. The second time I edit
> the item the script does not work and I can see that type
> is set to the original "appoinment" and item size has
> increased indicating that it is now a one-off. I assume
> that it becomes a one-off when saving after the first
> edit.
>
> I am setting the "PossibleValues" attribute in my code.
> It is a core feature of my project to dynamically set
> dropdown values based on web service calls.



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off