Adding (All) Options to Combo Boxes or List Boxes in Access 2007
Office 2007
Summary: Learn how to add an (All) entry to the list of items displayed in a list box or combo box in Access 2007.
Applies to: 2007 Microsoft Office System, Microsoft Office Access 2007
Joel Krist, Akona Systems
May 2007
Simple VBA for Selecting All
Here's a much simpler method for selecting all the items in a list box.
Private Sub btnSelectAll_Click()
Dim n As Integer
For n = 1 To Me.lstMyList.ListCount
Me.lstMyList.Selected(n) = True
Next
End Sub
To Unselect all items in the list box, use the same code but with "True" changed to "False."
Sheldon Penner
Private Sub btnSelectAll_Click()
Dim n As Integer
For n = 1 To Me.lstMyList.ListCount
Me.lstMyList.Selected(n) = True
Next
End Sub
To Unselect all items in the list box, use the same code but with "True" changed to "False."
Sheldon Penner
- 12/9/2011
- Sheldon M. Penner
Access tools
I am at best a self-taught hack at Access so please forgive me if I am way off base. However, here is my two cents on Microsoft Office tools.
Some times I am completely amazed to find a tool that does exactly what I want the way I want it. I feel like I hit the lotery. Other times, I am totally disappointed by how limited options in tools can be. This discussion on creating an All option in a combo box is a great example. Why can't the inclusion of an All option be a simple property of the tool? No, I have to use about 50 lines of code to accomplish this.
Similarly, the other day I was working to add a drop down box in an Excel 2003 file. I came across an article that discussed VBA code for making a default value appear for the drop down. Wow! Perfect for my project. But, alas, I was never able to get it work. Once again a Holy Grail was waved in front of me but my arms were too short to reach it.
At that time, as again after reading this article, I wonder why don't the tool have such options built in? Some tools have so many properties that it seems teams of programmers toiled for years to think of them. Yet, it seems they sometimes miss not-so-far-fetched uses. I think if I am looking to achieve X with a tool, I am sure hundreds of other users and several Microsoft employees would have thought of it long before me. Yet, the answer is often using some VBA code.
Some times I am completely amazed to find a tool that does exactly what I want the way I want it. I feel like I hit the lotery. Other times, I am totally disappointed by how limited options in tools can be. This discussion on creating an All option in a combo box is a great example. Why can't the inclusion of an All option be a simple property of the tool? No, I have to use about 50 lines of code to accomplish this.
Similarly, the other day I was working to add a drop down box in an Excel 2003 file. I came across an article that discussed VBA code for making a default value appear for the drop down. Wow! Perfect for my project. But, alas, I was never able to get it work. Once again a Holy Grail was waved in front of me but my arms were too short to reach it.
At that time, as again after reading this article, I wonder why don't the tool have such options built in? Some tools have so many properties that it seems teams of programmers toiled for years to think of them. Yet, it seems they sometimes miss not-so-far-fetched uses. I think if I am looking to achieve X with a tool, I am sure hundreds of other users and several Microsoft employees would have thought of it long before me. Yet, the answer is often using some VBA code.
- 6/9/2009
- General Ledger
- 7/8/2010
- Thomas Lee
Works great after changing to proper recordset type
Sometime ms will break there own rules and because old code in new programs. Change the
rst As Recordset to rst as DAO.Recordset and it will work. I could not get links and samples to download.
- 1/12/2010
- pduckworth
- 7/8/2010
- Thomas Lee
