Opening the Form: The Item_Open Function

When you open the form, the Item_Open event is triggered, which in turn calls the Item_Open function. It has several main tasks:

Display the Appropriate Form Page

Because the EnhancedLitCrit form consists of several pages, it uses script to make sure that the right page is displayed. Displaying the wrong page could, for example, prevent you from editing your own critique, or let someone else make changes to a critique that is not theirs.

This function, whose code you can see in EnhancedLitCrit, performs the following actions:

  1. Identify the current user, using the Application object of the Microsoft® Outlook® object model:
    CurrentUser = Application.GetNameSpace("MAPI").CurrentUser
    
  2. Check whether the current user is the same person who opened the form previously, if any:
    If Item.UserProperties("OldUserName") = CurrentUser Then
       If UserProperties("bibNo") <> 0 Then
          ' This person has reviewed a library item. Show HALF-READ form.
          MyInspector.ShowFormPage("HalfRead")
          MyInspector.HideFormPage("Others")
          MyInspector.SetCurrentFormPage("HalfRead")
          Set MyPage = MyInspector.ModifiedFormPages("HalfRead")
       Else
          ' Not a library item.  Show CURRENT USER form.
          MyInspector.ShowFormPage("CurrentUser")
          MyInspector.HideFormPage("Others")
          MyInspector.SetCurrentFormPage("CurrentUser")
          Set MyPage = MyInspector.ModifiedFormPages("CurrentUser")
       End If
    Else
       ' Reader is not submitter. Show DEFAULT (Others) form.
       MyInspector.SetCurrentFormPage("Others")
       Set MyPage = MyInspector.ModifiedFormPages("Others")
    End If
    
  3. As shown in the preceding code, if the two people are the same and the form contains a nonzero value for bib# (which means a corresponding title is in the FmLib database), display the HalfRead page, which allows critique input but no changes to the item description. This uses the GetInspector object of the Microsoft Outlook object model:
    MyInspector.ShowFormPage("HalfRead")
    . . . 
    MyInspector.SetCurrentFormPage("HalfRead")
    
  4. If the two people are the same but there is no bib# (no corresponding title is in the FmLib database), show the CurrentUser page, which lets the user change the item description and write a critique.
  5. If the current user is not the same as the person who wrote the critique originally, show the Others page, which is entirely read-only.

For more information, see Displaying the Form's Pages.

Display Dialog Boxes to Get a Title

Now, through the use of one or possibly two dialog boxes, the user has the opportunity to choose a title to review from the FmLib database. These are the steps in this task:

  1. Ensure that the custom property "Item Title" is empty (the form is being opened for the first time) before proceeding with the rest of the steps to find a title:
    If UserProperties("Item Title") = "" Then
    
  2. Start a CDO session to retrieve the name of the server:
    Set objCDOSession = Application.CreateObject("MAPI.Session")
    objCDOSession.LogOn "",False,False,False
    
  3. Open the MAPI Global Address List:
    Set objSession = Application.GetNameSpace("MAPI")
    Set MyAddressLists = objSession.AddressLists("Global Address List")
    
  4. Retrieve the address of the current user, which is later used as a parameter in the ChooseTitle method of the LitCritC component:
    Set MyEntry = MyEntries.Item(CurrentUser)
    LogOn = MyEntry.Address ' format: \o=\ou=\cn=\cn=alias
    
  5. Instantiate the LitCritC.Critique object:
    Set ObjCritique = Application.Createobject("LitCritC.Critique")
    
  6. Call the ChooseTitle method of the LitCritC.Critique object. See About the Critique.ChooseTitle Method. The ChooseTitle method returns the BibNo, Title, Authors, MediaType, and CritiqueNo variables of the title about to be reviewed:
    objCritique.ChooseTitle BibNo, Title, Authors,MediaType, ObjectID, CStr(LogOn), CStr(ServerName)