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

Combo - All option

Status
Not open for further replies.

megmogg

Programmer
Jul 14, 2005
76
GB


Hi All

Have a basic question.

I have a class for a combo drop-down which the user can type into and it finds the item in the list. This list comes from a SQL Server table.

Not wanting to hard code, what's the best way of adding an ALL option in the combo.

I know it could be a record in the table but I would have to hardcode somewhere so that I know it is "All" in the code.

Any suggestions?

Thanks

 
megmogg,

I might be missing something, but aren't you going to have to write code to deal with the "All" situation whatever method you use?

How are you getting the data from the SQL Server table into the the combo's RowSource?

Stewart
 


Thanks for the reply.

I might be missing something, but aren't you going to have to write code to deal with the "All" situation whatever method you use?

True, was thinking of something like using a -1 ID within the code to always handle this situation.

The data comes from SQL Server in the following way.
In the INIT of the combo class, it retrieves the SQL data into a local cursor then the combo picks up that local cursor. On requery of the combo, it goes back to SQL for the data.







 
I did think that if you could probably do a UNION select for "All records".

An alternative, which admittedly may not adhere to normal convention, is to have a check box beside the combo which the user can check for all records.


Hope that helps,

Stewart
PS If you want to get the best response to a question, please check out FAQ184-2483 first.
 


Regarding the check box, that is not what I really wanted as we have done that in the past and looks poor on forms.

Thanks for the replies. [thumbsup2]

Will have to think about it some more.

Was thinking of adding "All" to the cursor on init of the combo with an ID of -1 which I could then check for when using the value of the combo. This does not affect any data in the table then.



 
I did think that if you could probably do a UNION select for "All records".

That's how I do it but I use "--All--" as the expression so that it always sorts to the top of the list. The data is retrieved with a bit of SQL and I build the WHERE clause based on the user's selection from the combo. If the selection is "--All--" then I just delete the WHERE clause and get all records.

Geoff Franklin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top