List Items |
Remember this table structure from the database section?
There are actually four functions on the database object which deal with lists and list items.
GetHeadings returns the list of headings. Under each heading you can get a list of the items. You can use this to build a cascading menu if you wanted. The object structure reflects the database structure.
Set list = db.GetHeadings( enTableCategory ) For each heading in list msg = msg & heading.HeadingText & " contains " msg = msg & heading.Items.Count & " items" msg = msg & vbCrLf For each item in heading.Items msg = msg & " " & item.Text & vbCrLf Next Next
GetList returns all the items in one collection – very handy for building a simple drop-down. The list is filtered, but has no headings. It is easier to traverse the list in this format.
Set list = db.GetList( enTableCategory ) msg = list.Count & " items" & vbCrLf For each item in list msg = msg & item.Text & " " msg = msg & item.Tooltip msg = msg & vbCrLf Next
GetListItem returns one item that matches a particular id – very handy when you know what you want.
Set item = db.GetListItemByName( enTableCategory, "VIP Customer" ) MsgBox item.Tooltip,,item.Id & "=" & item.Text ```
Objects like Appointment and Contact have list item properties. You can access the item's text and id directly from the model:
Set cont = db.GetContact( 123 ) msg = "Contact " & cont.Name & " = " & cont.Category.Text MsgBox msg,,"Contact category"
You change a contact's category by assigning to the contact's category property:
Set item = db.GetListItem( enTableCategory, 123 ) Set cont = db.GetContact( 123 ) cont.Category = item cont.Save MsgBox "Changed category on " & cont.Name & " to " & item.Text
Up: Getting Started Prev: It all starts with the Database Object Next: Logging In Edit