PDA

View Full Version : Solved: Using SQL to build a drop-down list



GoKats78
02-03-2010, 05:43 AM
OK..I am really out of my element here...but..

it is possible to build a dropdown list in which the choices are called out in the SQL statement? and what would that statement look like?:dunno

Oorang
02-04-2010, 08:46 PM
Sure is. It's any valid Select Query. If the select query contains more than one column it uses the columns left to right depending on how many columns you set up your ComboBox/ListBox/ListView control to use. Columns exceeding the ComboBox.ColumnCount Property are just ignored. It's generally best to pull in only the column(s) you need though.


SELECT [MyTable].[MyField]
FROM [MyTable]
ORDER BY [MyField];

GoKats78
02-05-2010, 04:02 AM
Oorang..you missed, probably due to me not be clear, the real thrust of my question. I know it can be done that way...my question is with without having the choices in a table...but having them listed out in the actual SQL statement.

Oorang
02-05-2010, 09:47 PM
OIC:) AFAIK you can only "hard code" columns. You could try to pull something off with a crosstab, but remember aggregate only return numbers, so if your combobox is not numeric you're out of luck. Beside, that's asking to get shot by however has to maintain your code:)

There might be an alternative, what problem are you trying to solve?

stanl
02-08-2010, 03:43 AM
my question is with without having the choices in a table...but having them listed out in the actual SQL statement.

Do you mean the list exists as either a multi-select combo or listbox, then the choices are concatenated into an In("choice1",..."choice_n"):dunno or just a multiple WHERE...AND statement???