It is very important to note that the constituent code changes were not immediately committed to the database.
Remember, child objects do not have a save method; the top-level parent (in this case the oRecord object variable)
is responsible for the save. When we issue oRecord.Save, all the changes made are validated against any system
and end-user Business Rules. If the rules “pass” all the rule checks, the records are committed to the database. If a
rule fails to be validated, TheRaiser’s Edge raises a trappable runtime error. For example, one of the rules that
apply to constituent codes is the Date from field must come before (chronologically) the Date to field. So, in the
example above, if we had a constituent code child element that already has a date to of “12/12/1967”, TheRaiser’s
Edge would yield the following error.
As we mentioned earlier in this guide, this internal checking is paramount to preserving database integrity. You
simply cannot “corrupt” your Raiser’s Edge data from Visual Basic code. The same rules that apply to an end-user
apply to your data objects.
Accessing Specific Child Elements
Like any Visual Basic collection, Raiser’s Edge child objects can be accessed directly via the Item method. Things
become more advance here. Since a Raiser’s Edge child collection is providing high-level access to underlying
database records, the developers at Blackbaud needed to “overload” the behavior of the item method, providing
multiple ways to use it depending on the context of how it is accessed. For example, if you pass in a string (For
example, “66”), the Item method returns the child object whose database ID field is equal to 166. If you pass in a
number (For example, 166), then the item method will return the “nth” member of the collection.
To ensure consistent access to collections across the object model, we provide these two different methods. The
most common use of the Item method of a child collection is to pass it a numeric parameter, accessing the nth item.
This becomes more evident when we discuss sorting later in this section. When we work with top-level collections,
the value of accessing collection elements via the database ID becomes more clear.
'Access the 5th element in the collection
'Access an element of the collection that has an
' underlying database id (primary key) of 5.