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!

Combo box property

Status
Not open for further replies.

monarips

Programmer
Joined
Sep 18, 2003
Messages
2
Location
CA
Dear friends,
plz help me out in setting the property of the combo box ...
the property of ALL where if the user selects the all field then all the results are shown.
example in a table of category_id .
a combo box showing the category_Id .
Table Category
fields
Category_Id
and Category_Name
values
1 Cars
2 Trucks
if the user selects ALL in combo box then all the results should be shown.
so a combo box should have values
All
1
2
plz tell me if u understand.
Thanks a ton in advance
mail at monarips@yahoo.ca
Thanks
Mona
 
Just add a row to the category lookup table for 'All' and then base a query on the result.

0 All
1 Cars
2 Trucks

In the AfterUpdate() for the combo, just change the recordsource for the form or whatever using a where clause:

Code:
Private Sub cboCategory_AfterUpdate()
  Dim strWhere As String
  
  If Me!cboCategory = 0 Then
    strWhere = ""
  Else
    strWhere = " WHERE [VehicleType]=" & Me!cboCategory
  End If

  Me.RecordSource = "SELECT * FROM Vehicles" & strWhere

End Sub

VBSlammer
redinvader3walking.gif

Unemployed in Houston, Texas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top