Display description but save code, how?

  • Thread starter Thread starter David
  • Start date Start date
D

David

I have a table containing codes and descriptions. I need
to display the descriptions in my combo box control but
I'd like to save the code in my table not the description.
Is there an easy way to do this?
When the form is redisplayed, I want the description
associated with the previously selected code to display.
 
The wizard should do a good job of setting this up for you.

If you insist on doing it manually (and I don't see why you should then)
open the property sheet of the combo box and set it up as follows:

- Set the Row Source Type to Table/Query
- In row source select your table then click the ellipsis (...) to open the
query builder. Select your code and descriptions fields (in that order). Set
the query to order the rows how you wish (probably by description). Close
the query builder and answer "Yes" when prompted.
- Set the column count to 2.
- Set the bound column to 1.
- Set column widths to 0
- Make sure the control is bound to the field where you want to store the
code value (set its control source).
 
I'm totally lost, I never use the query builder as I've
never been able to figure out how it works, it puts a
thing called '<Expr>' between the column names and there
is no way to specify a sort order as you say. I'm using
Access 2000.
I already built a query, why can't I use that? Also I
don't see any property called 'column count'???
 
David,

You can use the combobox 'Wizard' to build this for you. In
your form design go to your controls toolbar and make sure
that the wizard button ( the one with the magic wand ) is
depressed and then drop a combo box on your form. As you
follow through the wizards choices of looking up from a
table, query or list, choose your query. Select your code as
the first field, then your description as the second field.
Select the Code field as the field to bind the combobox to.
You should be presented the opportunity to check a box that
says 'Hide Key Field'. If so, check that. If not, when you
get to the part that lets you resize the width's, totally
collapse the first field, effectively setting the width to
'0"' as Andrew mentioned in his post. Finish out the wizard
and you should have what you want with the description being
displayed, but the hidden Code will be what is stored.

--

Gary Miller
Gary Miller Computer Services
Sisters, OR
________________________
 
Back
Top