UserProperty.ValidationFormula property (Outlook)

Returns or sets a String indicating the validation formula for the user property. Read/write.

Syntax

expression. ValidationFormula

expression A variable that represents a UserProperty object.

Remarks

The validation formula is used by Outlook to validate the Value property when an item is saved.

Example

The following Visual Basic for Applications (VBA) example demonstrates the use of ValidationText and ValidationFormula properties.

Sub TestValidation() 
 
 Dim tki As Outlook.TaskItem 
 
 Dim uprs As Outlook.UserProperties 
 
 Dim upr As Outlook.UserProperty 
 
 
 
 Set tki = Application.CreateItem(olTaskItem) 
 
 tki.Subject = "Work hours" 
 
 tki.TotalWork = 3000 
 
 Set uprs = tki.UserProperties 
 
 Set upr = uprs.Add("TotalWork", olFormula) 
 
 upr.Formula = "[Total Work]" 
 
 upr.ValidationFormula = ">= 2400" 
 
 upr.ValidationText = """The WorkHours (Total Work) should be equal or greater than 5 days """ 
 
 tki.Save 
 
 tki.Display 
 
 MsgBox "The Work Hours are: " & upr.Value 
 
End Sub

See also

UserProperty Object

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.