none
text box and combo boxs - Outlook Custom Form RRS feed

  • Question

  • I'm really new at this Outlook Custom Form thing...

    I've create a custom form, with a combo box (which I have populated with my desired choices), but I can't seem to do anything with it...
    Normally in other languages, I would use objectName_changed() but it doesn't work. The online help example show it as Item_PropertyChange().. which is confusing to me, since it's not the "Message" form but the control that changes.
    I'm trying to select a value from a comboBox and whatever I select, it should populate a text field on the form...

    The comboBox property name is "cbDepartments" ....

    Sub Item_PropertyChange()
     Set dataForm = Item.GetInspector.ModifiedFormPages("Message")
     set userDepartment = dataForm.Controls("cbDepartments")
     Set userDept = dataForm.Controls("txtUserDept")
     userDeptcode = getDeptCode ( userDepartment )   // translates Department Name to it's Code number (which works...ie..060)
     userDept.Text = userDeptcode
    End Sub

    I'm really lost with this VBA/VBScript stuff, as there doesn't seem to be rules as to where and what you can use when...
    In this case, it appears the event is wrong..but I'm not sure...

    Really could use some guidance...
    Thank You,
    Brett

    Monday, September 11, 2017 9:48 PM

Answers

  • Hi bflagg,
    Most Microsoft Forms 2.0 controls in an Microsoft Outlook custom form support only one event, the Click event. 
    I think you have to use click event to do this.
    Here is the example
    Sub cbDepartments_Click()
    Set dataForm = Item.GetInspector.ModifiedFormPages("Message")
    set userDepartment = dataForm.Controls("cbDepartments")
    Set userDept = dataForm.Controls("txtUserDept")
    userDept.text=userDepartment.value
    End Sub
    Please refer to below link for more information.
    https://msdn.microsoft.com/en-us/vba/outlook-vba/articles/control-events?f=255&MSPPError=-2147217396
    Best Regards,
    Terry

    • Edited by Terry Xu - MSFT Tuesday, September 12, 2017 5:05 AM
    • Marked as answer by bflagg Tuesday, September 12, 2017 1:12 PM
    Tuesday, September 12, 2017 5:04 AM

All replies

  • Hi bflagg,
    Most Microsoft Forms 2.0 controls in an Microsoft Outlook custom form support only one event, the Click event. 
    I think you have to use click event to do this.
    Here is the example
    Sub cbDepartments_Click()
    Set dataForm = Item.GetInspector.ModifiedFormPages("Message")
    set userDepartment = dataForm.Controls("cbDepartments")
    Set userDept = dataForm.Controls("txtUserDept")
    userDept.text=userDepartment.value
    End Sub
    Please refer to below link for more information.
    https://msdn.microsoft.com/en-us/vba/outlook-vba/articles/control-events?f=255&MSPPError=-2147217396
    Best Regards,
    Terry

    • Edited by Terry Xu - MSFT Tuesday, September 12, 2017 5:05 AM
    • Marked as answer by bflagg Tuesday, September 12, 2017 1:12 PM
    Tuesday, September 12, 2017 5:04 AM
  • thank you.. 

    That was it...

    Tuesday, September 12, 2017 1:13 PM