How do I validate a field in a Outlook 2003 Form

G

Guest

Hi,

I wonder if you could help me. I am having difficulties with validating
fields in an Outlook 2003 form.

Region: 1l Area: a, b
Region: 2l Area: c, d
Region: 3l Area: e, f

In my form I have created a ComboBox called “Region†containing values 1, 2
and 3. The values in my next ComboBox called “Area†should be dependent on
the value selected in the first ComboBox “Region†e. g. if a user selected
Region “1â€, in Area there should be values “a†and “bâ€, if a user selected
Region “2â€, in Area there should be values “c†and “d†and so on…

I would be very grateful if you could help me

Thanks

Zuzana
 
S

Sue Mosher [MVP-Outlook]

Some missing info: Are Region and Area the names of Outlook custom properties? Is Area a multi-select combo box since you' talking about it having multiple values? (Can't say that I've ever seen one)
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
G

Guest

Dear Sue,

Thank you for your response. As you are probably aware, from my first email,
I am a novice in this area, therefore I am not sure what you mean by Outlook
custom properties. However, in answer to your second question, both "Region"
and "Area" are Multi-select combo boxes, each of which contains a list of
values. What I am trying to do is make the list of values in the "Area" combo
box dependent on the selection from the "Region" combo box.

Thank you for your help

Zuzana
 
S

Sue Mosher [MVP-Outlook]

Outlook uses properties to store data in items. A control on a custom form can be bound to a custom property, so that data entered into the control is stored in the property, and data in the property is visible in the control. A control can also be unbound. In that case, Outlook discards any data in the control when the item is saved.

The distinction is important for many reasons: Whether a control is bound or unbound determines (a) what event to use to respond to the user's interaction with the control, (b) the best syntax for accessing the data value in the control, (c) whether the data in the control can be used in a validation formula.

The Properties dialog for the control tells you on its first tab the name of the control, and on its second tab, the name of the field, if any, that is bound to the control. We need both pieces of informaton -- the name of the control and the name of the property, if any, that the control is bound to.

Also, since Region is a multi-select combo box, can you give an example of how multiple selections in it would affect the Area box?
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
G

Guest

We will have two boxes:

1/ "Region" as a multiple combo box which contains values 1, 2, 3 and 4;
2/ "Area" combo box which contains values a, b, c, d, e, f, g, h.

If a user selects 1 from the "Region", multiple combo box, then I want the
“Area" multiple combo box to display, ONLY, the values "a" and “b".

If 2 is selected from the "Region" multiple combo box, then I want the
"Area" multiple combo box to display, ONLY, the values "c" and "d".

If 3 is selected from the "Region†multiple combo box, then I want the
“Area" multiple combo box to display, ONLY, the values "e" and “f".

And finally,

If 4 is selected from the "Region" multiple combo box, then I want the
"Area" multiple combo box to display, ONLY, the values "g" and "h".
 
S

Sue Mosher [MVP-Outlook]

Still need to know about the properties, not just the controls.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
G

Guest

Properties:

Display tab

Name: ComboBox2

Settings:
Visible
Enabled
Sunken

Value tab

Choose Field: Region
Type: Text
Format: Text
List Type: Dropdown
Property to use: Value
Possible Values: 1; 2; 3; 4;
_________________________________
Display tab

Name: ComboBox3

Settings:
Visible
Enabled
Sunken


Value tab

Choose Field: Area
Type: Keywords
Format: Text
List Type: Dropdown
Property to use: Value
Possible Values: a; b; c; d; e; f; g; h
 
G

Guest

Hi Sue,

I haven't heard from you for a while. Any progress with this issue?

Kind Regards

Zuzana
 
S

Sue Mosher [MVP-Outlook]

Sorry for the delay. The code would look like this, but you need to replace P.2 with the name of the actual page where the ComboBox3 control is located:

Sub Item_CustomPropertyChange(ByVal Name)
Select Case Name
Case "Region"
Call SetCombo3
End Select
End Sub

Sub SetCombo3()
Set objInsp = Item.GetInspector
Set objPage = objInsp.ModifiedFormPages("P.2")
Set ComboBox3 = objPage.Controls("ComboBox3")
Select Case Item.UserProperties("Region")
Case "1"
ComboBox3.List = Split("a,b", ",")
Case "2"
ComboBox3.List = Split("c,d", ",")
Case "3"
ComboBox3.List = Split("e,f", ",")
Case "4"
ComboBox3.List = Split("g,h", ",")
End Select
End Sub

To understand what this code is doing, I suggest you check out my pages at http://www.outlookcode.com/d/propsyntax.htm and http://www.outlookcode.com/d/formcontrols.htm#listcombo

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and 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