Is it possibe to create a combo box with more than 1 control sourc

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form with multiple combo boxes. The combo boxes have several
columns. I need to be able to store the unique ID # in one field, and the
name assosciated with the unique ID for another. Currently I have a work
around where I use a second Combo box that is filtered to only show the name
assosciated with the unique ID that is input by the 1st box. I could also
create a listbox that displays only the information I want, but it won't
select it and input it into the table without clicking on it. If there is a
way to eliminate the extra step it would help me greatly. The information I
want is displayed in the columns of the combo box, but I need the ID and the
name stored in different columns in the table. I hope I was clear on what I
am trying to do.
 
You don't need to store the name as well as the ID# in the form's underlying
table, only the latter as from this you can always get the name from the
referenced table via a query which joins the tables. More importantly you
should not do so; to have a column for the name as well as the ID# in the
referencing table introduces redundancy and the risk of inconsistent data.

You can show the names on the form by means of a single combo box bound to
the ID column, but which shows the name and hides the ID, whose value is
usually irrelevant to the user. Lets assume a combo box which looks up a
table Customers with columns CustomerID, FirstName and LastName. Set up the
combo box along these lines:

RowSource Property:

SELECT CustomerID, FirstName & " " & LastName AS FullName FROM Customers
ORDER BY LastName, FirstName;

Other Properties:

BoundColumn 1
ColumnCount 2
ColumnWidths 0cm;8cm (or rough equivalent in inches but the first
dimension must be zero to hide the first, CustomerID, column, so only the
name shows.

Ken Sheridan
Stafford, England
 

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