Combobox rows populated from different fields

  • Thread starter Thread starter Renster
  • Start date Start date
R

Renster

Folks,

I have a table that is something like :

(key) Version number
StatisticName1 string
StatisticName2 string
StatisticName3 string
....

On a form I have a combobox that I wish to populate with the values in
StatisticName1, StatisticName2 etc, depending on the value of Version.
ComboboxName.RowSource = "SELECT StatisticName1, StatisticName2..."
doesnt work of course, as that treats the different stat names as
COLUMNS in the combo, not rows....

Help

TIA

Steve
 
Wayne,

I may have missed the point of what you wrote, but Im comfortable
writing queries like that. However, what I am trying to achieve is
different from the norm. Ordinarily a query such as the one you wrote
will return a recordset of "n" records from the one field
(TableName.FieldName). I wish to return a recordset made up of *1*
record from each of "n" fields.

eg:

(key)Reference Field1 Field2 Field3
--------------------------------------------------------------------
1 ref1f1 ref1f2 ref1f3
2 ref2f1 ref2f2 ref2f3
3 ref3f1 ref3f2 ref3f3

I want to populate a combobox such that, if for example I pass "where
Reference = 2" as a filter, the combobox is filled:

ref2f1
ref2f2
ref2f3

Hope this makes my problem a little clearer

Steve


Hi

Try something like

SELECT [TabeName].[FieldName] FROM [TableName] ORDER BY [FieldName];

--
Wayne
Manchester, England.



Renster said:
I have a table that is something like :
(key) Version number
StatisticName1 string
StatisticName2 string
StatisticName3 string
....
On a form I have a combobox that I wish to populate with the values in
StatisticName1, StatisticName2 etc, depending on the value of Version.
ComboboxName.RowSource = "SELECT StatisticName1, StatisticName2..."
doesnt work of course, as that treats the different stat names as
COLUMNS in the combo, not rows....


Steve- Hide quoted text -- Show quoted text -
 
Sorry I though you were working on a form
On a form I have a combobox that I wish to populate with the values in

Tom has given you the answer

Good luck with your project
 
Tom,

Thanks very much for that, worked a treat.

Steve

Hi Steve,

Your table does not appear to be properly normalized. However, perhaps
basing your SELECT statement on a Union query will work for you.

qUNIFieldValues (saved query)

SELECT Reference, Field1 AS [FieldValue] FROM TableName
WHERE Field1 is not null
UNION
SELECT Reference, Field2 AS [FieldValue] FROM TableName
WHERE Field2 is not null
UNION
SELECT Reference, Field3 AS [FieldValue] FROM TableName
WHERE Field3 is not null
ORDER BY [FieldValue]

For your combo box:

SELECT [FieldValue]
FROM qUNIFieldValues
WHERE Reference = 2;

Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/e...http://www.access.qbuilt.com/html/search.html
__________________________________________



Renster said:
I may have missed the point of what you wrote, but Im comfortable
writing queries like that. However, what I am trying to achieve is
different from the norm. Ordinarily a query such as the one you wrote
will return a recordset of "n" records from the one field
(TableName.FieldName). I wish to return a recordset made up of *1*
record from each of "n" fields.

(key)Reference Field1 Field2 Field3
I want to populate a combobox such that, if for example I pass "where
Reference = 2" as a filter, the combobox is filled:

Hope this makes my problem a little clearer
Steve- Hide quoted text -- Show quoted text -
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top