none
VB Script that refers to a check box or option button on a custom Outlook Form no longer works once I bind either control to a field. RRS feed

  • Question

  • I have a custom Outlook form on which there is an option button set and two combo boxes.

    • The option buttons are named SEEKYes and SEEKNo. They are not bound to any fields.
    • The combo boxes are named ComboBoxSEEKCategories and ComboBoxSEEKSubCategories. They are bound to custom fields, populated with data at run time. 

    When a user is presented with the form, the combo boxes are initially disabled (but visible). Upon ticking the SEEKYes check box, the combo boxes become enabled. Similarly, upon ticking the SEEKNo check box, the combo boxes become disabled again.

    I am using the following code for this functionality:

    Sub SEEKYes_Click()
    Item.GetInspector.ModifiedFormPages("Message").ComboBoxSEEKCategories.Enabled = True
    Item.GetInspector.ModifiedFormPages("Message").ComboBoxSEEKSubCategories.Enabled = True
    Item.GetInspector.ModifiedFormPages("Message").LabelSEEKCategory.Enabled = True
    Item.GetInspector.ModifiedFormPages("Message").LabelSEEKSubCategory.Enabled = True
    End Sub

    Sub SEEKNo_Click()
    Item.GetInspector.ModifiedFormPages("Message").ComboBoxSEEKCategories.Enabled = False
    Item.GetInspector.ModifiedFormPages("Message").ComboBoxSEEKSubCategories.Enabled = False
    Item.GetInspector.ModifiedFormPages("Message").LabelSEEKCategory.Enabled = False
    Item.GetInspector.ModifiedFormPages("Message").LabelSEEKSubCategory.Enabled = False
    End Sub

    The issue I am having is as follows:

    • A user can complete the form and email it to me. However, upon my receiving it, although the combo boxes show me the selections the user has made, the SEEKYes check box appears unticked (where it should be ticked). I understand that this is because the SEEKYes check box is not bound to an underlying field. Similarly, if a user ticks the SEEKNo check box instead, it too arrives unticked (I have no idea if they've ticked that box unless I ask them)
    • If I then bind both the SEEKYes and SEEKNo check boxes to custom fields, upon the form arriving in my email, I can now clearly see which check box the user has ticked. This is good.
    • However, once either of the SEEKYes or SEEKNo check boxes has been bound to an underlying field, the script to react to their click events no longer functions i.e. a user can still tick the SEEKYes check box, but the related combo boxes remain disabled, whereas the code says they should become enabled.

    I have tried code that supposedly allows me to listen for other events. I've tried code that's supposed to read the value recorded to the fields associated with the two check boxes. I've tried numerous code examples, trawling the internet for days now for a resolution. Regardless of what I've tried, regardless of the success other people have had resolving the same scenario I have, I cannot get this to work. It seems to me that as soon as I bind either a check box or option button (I thought I'd try them too) to a field, no amount of vbscript can read events applied to those controls or changes to the data within the fields they are bound to. I'm at a total loss. 

    Monday, February 24, 2014 11:26 PM

Answers

  • See http://www.outlookcode.com/article.aspx?id=38 and other articles on forms at www.outlookcode.com for lots of information on custom forms.

    Bound controls like a checkbox should fire the PropertyChange or CustomPropertyChange event in your VBS code, depending on the sort of property to which the control is bound.

    You can use CustomPropertyChange in this case as you have the controls bound to custom fields. Check which property was changed when the event fires and you should be good to go.


    Ken Slovak MVP - Outlook

    Tuesday, February 25, 2014 3:31 PM
    Moderator