Examples: SortByExisting property


The following procedure runs when the user clicks a button added to the Customer Maintenance window using the Modifier. It uses the SortByExisting method to sort the CustomerCollection by the collection’s Date Added property. It then creates a report file using the VBA Open statement, and prints the object’s ID, property names and property values to the file using the VBA Print# statement. Only data objects that include the Date Added property will be printed, and will be sorted by date:

Private Sub PrintByDateButton_AfterUserChanged()
	Dim CustomerCollection As DUOSObjects
	Dim CustomerObject As DUOSObject
	Dim CustomerProperty As DUOSProperty
	Dim CustomerProperties As DUOSProperties

	Set CustomerCollection = DUOSObjectsGet("CustomerCollection")

	'Sort the collection by the date the customer was added
	CustomerCollection.SortByExisting = "Date Added"
	'Create a text file for the report
	Open "CustomerReport.txt" For Output As #1
	For Each CustomerObject In CustomerCollection
		Print #1, CustomerObject.ID
		Set CustomerProperties = CustomerObject.Properties
		For Each CustomerProperty In CustomerObject.Properties
			Print #1, " " + CustomerProperty.Name + " - " + _
			CustomerProperty.Value
		Next
	Next
End Sub


Documentation Feedback