Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add "ALL" value to combo box.

Status
Not open for further replies.

fperri

Programmer
Apr 25, 2007
8
US
I have a combo box that pulls the data from a table. Is there anyway for me to add an "ALL" option to the list?
 
By the way I've tried....

Me.cboLender.AddItem ("ALL",0)

I get the compile error "Expected: ="

....and I am using Access 2002 if this helps
 
If you search the Access forums, you'll see some answers to this question. However, you can create a union query. This can only be done in SQL (create a new query and then select SQL View from the View button). Here's an example:

SELECT DISTINCT [County] FROM tblParcel WHERE [County] Is Not Null UNION Select '<All_Counties>' From tblParcel
ORDER BY [County];

Then place the query name on the RowSource of the UNbound combobox.

Then you have to test for the All condition in code. So on a command button's OnClick event or the combobox AfterUpdate event, you'd put something like:

If Me![countycombo].Value = "<All_Counties>" Then
WClause = "([County] Like " & "'*' Or [County] Is Null)"
Else
WClause = "[County] = " & "'" & Me![countycombo] & "'"
End If

The above is just an example.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top