Microsoft KB Archive/216438

= OL98: How to Simulate More Than Two Form Interfaces =

Article ID: 216438

Article Last Modified on 7/31/2001

-

APPLIES TO


 * Microsoft Outlook 98 Standard Edition

-



This article was previously published under Q216438





SUMMARY
This article illustrates how you can use multiple forms to simulate more than two interfaces when creating a solution using Outlook forms.



MORE INFORMATION
An Outlook form can have two interfaces, or sets of pages--one for composing, the other for reading. Some solutions, such as a survey application, may require more than two interfaces. For example, a survey form often requires three user interfaces:
 * For the person to send out the survey
 * For the recipient to fill out the survey
 * For someone to view the responses

The following steps illustrate an approach that you can use to simulate more than two interfaces in a form's solution. This example does not create a fully functional survey solution. These steps are a starting point for creating a much larger form solution. To implement this type of survey solution, you must have a good understanding of Outlook custom forms. It may also be helpful to have programming experience.

Create the Main Survey Form

 * 1) On the File menu, click New, and then click Mail Message.
 * 2) On the Tools menu, click Forms, and then click Design This Form.

You are now looking at the compose pages of the form.
 * 1) Make a change to the Message form page that indicates you are looking at the compose pages of the form. For example, you can delete the large Message control, add a Label control, and than change the text to This is the survey that the user will fill out.
 * 2) Click the Edit Read Page button on the toolbar to switch to the read pages of the form.
 * 3) Delete the large Message control and then add a Label control, and then change the text to This is page that will contain the compiled results.
 * 4) Click the Properties page of the form, and then click to select the Use form only for responses check box. This makes the actual survey form hidden in the forms library so that users cannot start it directly.
 * 5) On the Tools menu, point to Forms, and then click Publish Form. Make sure that the Look in box says Personal Forms Library.
 * 6) Set the Display Name box to My Survey, and then click OK. When prompted to enable the Save form definition with item option, click No.NOTE: Typically a message form is published in the Organizational Forms Library on the Microsoft Exchange Server, but for illustrative and testing purposes, here it is published in your Personal Forms Library.


 * 1) Quit Outlook, and do not save changes to the form.

Create a Form to Start the Survey Form
 On the File menu, click New, and then click Mail Message. On the Tools menu, click Forms, and then click Design This Form.  On the Form menu, click View Code. Enter the following Visual Basic Scripting Edition (VBScript) code, and then close the Script Editor. Be sure to change the strSurveyCollector variable so that it contains your e-mail address. Dim iOldItemFlag Const strSurveyCollector = "janedoe@mycompany.com" Const strSurveyForm = "IPM.Note.My Survey"

Function Item_Read ' Read event only fires for existing items, not new ones, so  ' this flag is used to indicate whether or not a new item is   ' being created. iOldItemFlag = 1 End Function Function Item_Open Dim objNS Dim objOutBox Dim objSurvey If iOldItemFlag = 1 then Set objNS = Application.GetNameSpace("MAPI") Set objOutBox = objNS.GetDefaultFolder(4) ' 4=olFolderOutBox Set objSurvey = objOutBox.Items.Add(strSurveyForm) objSurvey.To = strSurveyCollector objSurvey.Display Set objSurvey = Nothing Set objOutBox = Nothing Set objNS = Nothing Item.Close 1 End If End Function

 Make a change to the Message form page to indicate that this is the user interface for initiating the survey. For example, this page may provide the ability to select which recipients should receive the survey. For now, you can delete the large Message control, add a Label control, and then change the text to This is where the person sending the survey can select recipients, enter questions, and so on. On the Tools menu, point to Forms, and then click Publish Form. Make sure the Look in box says Personal Forms Library. Set the Display Name to Launch Survey, and then click OK. When prompted to enable the Save form definition with item option, click No.NOTE: Typically, a message form is published in the Organizational Forms Library on the Microsoft Exchange Server, but for illustrative and testing purposes, here it is published to your Personal Forms Library.

</li> Quit Outlook, and do not save changes to the form.</li></ol>

Test the Example

 * 1) Open the Launch Survey form from the Personal Forms Library. This presents the first user interface. This interface can be used to select recipients and perform other initial tasks related to the survey. For this example, address the survey to yourself and then send the form.
 * 2) You receive the Launch Survey form in your Inbox. When you open the form, the Read event is initiated and sets a flag indicating that the Launch Survey form is being opened (not started).
 * 3) The Open event is initiated directly after the Read event is initiated. Because the flag was set in the Read event, the Open event starts the My Survey form, and then automatically closes itself; the recipient only sees the read pages of the My Survey form. This is the second user interface.
 * 4) The survey form that the recipient fills in is pre-addressed to whoever sent the survey, in this case, you. This was done by setting the To field in the VBScript code.
 * 5) Click Send to indicate that the survey is complete; this sends the My Survey form back to the originator.
 * 6) As the originator, open the completed survey form from your Inbox. You will see the read pages of the form, or the third user interface.

<div class="references_section">