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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

combo box 1

Status
Not open for further replies.

EscapeUK

Programmer
Jul 7, 2000
438
GB
I can populate the combo box very well with the following code.

Combo0.RowSource = "SELECT DISTINCTROW [dbo_MyData].[ID], [dbo_MyData].[Description] FROM [dbo_MyData];"

This displays two lists.

How at the first option I would like displayed in the combo box is 0 then ALL.

Then the data from the select would be displayed.

The combo would then look like:

0 All
1 Blue
33 Green
88 Red

If you can help please provide as much simple info and instructions s possible as I am new to this.

ta
 
Use the Order By command to give into Ascending order

SELECT DISTINCTROW [dbo_MyData].[ID], [dbo_MyData].[Description] FROM [dbo_MyData] ORDER BY [dbo_MyData].[ID];
 
sorry the values 0 and all are not in the database.
 
Second of all the default is that when you click on the form all records are displayed if you will not select something from the combo box.
 
There is a "proper" way to do this. There is also this way...
Code:
SELECT DISTINCTROW [dbo_MyData].[ID], [dbo_MyData].[Description] FROM [dbo_MyData]
UNION
SELECT 0, "All" FROM [dbo_MyData];

HTH John

Use what you have,
Learn what you can,
Create what you need.
 
it is not possble for me to enter 0 and all into the database another app I have no control over uses the database.

 
EscapeUK,

Don't enter zero. Just put it in the query. Put it in any query. It doesn't matter what is in the table as long as you use a valid table name.

Try it. John

Use what you have,
Learn what you can,
Create what you need.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top