Need help linking combo box of column headings to a query

G

Guest

Can someone help me--
I have a combo box that contains the column headings (of yes/no columns)
from a table. I need to know how to make the selection in the combo box
transfer over to the query. After someone selects valueA in the combo box I
need the system to go find the column called valueA and insert "=Yes" and
then provide the results. I know this sounds confusing but any help would be
greatly appreciated. If I can't figure this out, my only option is going to
be to have a query for each column.....and that is a lot of queries!
 
T

Tim Ferguson

Can someone help me--
I have a combo box that contains the column headings (of yes/no
columns) from a table.

This sounds like a Design Problem. Shouldn't these columns be records in
a related table?
I need to know how to make the selection in
the combo box transfer over to the query. After someone selects
valueA in the combo box I need the system to go find the column called
valueA and insert "=Yes" and then provide the results. I know this
sounds confusing but any help would be greatly appreciated. If I
can't figure this out, my only option is going to be to have a query
for each column.....and that is a lot of queries!

Nono: you need a new table with a _record_ for each yes or no... then the
whole thing becomes a simple INSERT statement.

Instead of this:

FName Green Red Blue Yellow
Eric Yes No No
Fred Yes Yes No No


you have

FName Colour Answer
Eric Green Yes
Eric Red No
Eric Yellow No
Fred Green Yes
Fred Red Yes
Fred Blue No
Fred Yellow No


Hope that helps


Tim F
 
G

Guest

Your suggestion makes sense, however, I designed it this way because each
record has an employee number associated to it and that is the primary key
throughout the entire database - so I can't have duplicate lines.

Thanks for the help though.

Shanna
 
D

Douglas J Steele

In Tim's example, the primary key would be the combination of fields FName
and Colour.

You'd still want your existing Employee table with Employee number as its
primary key, and you'd create a second table that has its primary key as the
combination of fields.
 
T

Tim Ferguson

Your suggestion makes sense, however, I designed it this way because
each record has an employee number associated to it and that is the
primary key throughout the entire database - so I can't have duplicate
lines.

Like Doug says...

I just wanted to point out that a Primary Key applies to a table, not to a
database. In general, if two tables have the same PK, then there is very
probably a Major Design Problem.

All the best

Tim F
 

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

Top