Did not close the form after click on an action button.

R

Richard

I have create a custom form for vacation request. Once the manager
receive the application, he/she will click on an custom action button
"approve" or "reject". However, after they click on either action
button, the form has no problem sending back to the applicant but it
won't be closed and they have to close it manually. In this case, I
have added some VB code into the form, but it seems it doesn't work at
all.

Sub Item_CustomAction(ByVal Name)
Select Case Name
Case "Approved"
item.close(0)
Case "Rejected"
item.close(0)
End Select
End Sub

I'll be grateful if anyone will tell me what's wrong with the script.

Thanks!

Richard
 
S

Sue Mosher [MVP]

Outlook version? Where is the form published? Does other code on the form run?
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 
R

Richard

My outlook version is 2002 and a few users will use 2000.

Yes, I have a command button on the "Compose page" for
users to submit their application.

Sub SubmitForApproval_Click()
Item.Send
End Sub

It seems whatever code I put in, it only runs for
the "Compose page". How do I write the code to run for
the "Read Page"? For example, closing the form after the
manager clicking on an action button "Approve".

Many Thanks!

Richard
 
S

Sue Mosher [MVP]

There are two major causes of code in an Outlook form not running -- 1) security settings in Outlook 2003 and 2) the broader form script security features introduced with the Outlook Email Security Update.

#1: Outlook 2003 includes a new setting -- turned off by default -- to allow forms in shared mailboxes to run script. You can change the setting by choosing Tools | Options | Other | Advanced Options and checking the box for Allow script in shared folders. See http://www.slipstick.com/dev/ol2003problems.htm#mailboxscript for more information on this setting and a comparable one (on by default for public folders).

#2: 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.slipstick.com/outlook/esecup.htm#formsec 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
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 

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