Examples: Exists property

The following procedure runs for a button in a VBA user form. It uses the Exists property to check whether the Item Color property exists for a given data object. If the property doesn’t exist, the procedure creates it using the collection’s Item property:

Private Sub CheckItemColor_Click()
	Dim ItemCollection As DUOSObjects
	Dim ItemObject As DUOSObject
	Dim ItemProperties As DUOSProperties

	Set ItemCollection = DUOSObjectsGet("ItemCollection")
	Set ItemObject = ItemCollection(ItemNumber)
	Set ItemProperties = ItemObject.Properties

	If ItemProperties.Exists("Item Color") = False Then
		'This item has no color property
		ItemProperties.Item("Item Color") = InputBox("Enter a " + _
		"color for this item.")
		'Set the window field
		ItemColor = ItemProperties.Item("Item Color")
	End If
End Sub

Documentation Feedback