• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 7. Exploring VBA in Microsoft Ac... > Programmatically Add Items to a List...

7.5. Programmatically Add Items to a List or Combo Box

7.5.1. Problem

Getting items into a list or combo box from a data source is elementary in Access. Sometimes, though, you need to put into a list box things that you don't have stored in a table. In Visual Basic and other implementations of VBA, this is simple: you just use the AddItem method. But Access list boxes don't support this method. How can you add to a list box items that aren't stored in a table?

7.5.2. Solution

It's true: Access list boxes (and combo boxes) don't support the AddItem method that Visual Basic programmers are used to using. To make it easy for you to get bound data into list and combo boxes, the Access developers had to forego a simple method for loading unbound data. To get around this limitation, there are two methods you can use to place data into an Access list or combo box: you can programmatically build the RowSource string yourself, or you can call a list-filling callback function. Providing the RowSource string is easy, but it works in only the simplest of situations. A callback function, though, will work in any situation. This solution demonstrates both methods.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint