Combo box. How do I assign a value?

F

Frank Martin

On a form I have a combo box based on a table "tblNames".

This tblNames has two fields NameID and Name.

I have made the combo box on the form look up this table, and I have done
this by invoking a query so as to sort the names, but also to make use of
the "autolookup" feature of the combo, because there are
so many names in the table.

Although I select the name via the "autolookup", what I need placed back in
the field of the combo is the NameID, but I cannot manage this.

Please help, Frank
 
A

Albert D. Kallal

Just build the combo box on the form using the wizard.

You can select the query you made for the source of this combo box. You
simply select the two fields. If the combo box wizard does NOT hide the
first column for you, then simply re-size it so small as to hide the first
column. The result will be a combo box that searches and displays via the
Name field, but in fact stores the NameID in the field you bind the combo
to.

So, give the wizard a try, it should build what you want with great ease.

Also, to avoid confusing and problems, you at all costs avoid the lookup
feature in the table design mode...right?
 
S

Sandra Daigle

Just one other thing to add to what Albert has said - you might want to
change your 'Name' field to something slightly different since Name is an
Access reserved word and a common property Name. Odd things can happen when
there are conflicts with Named properties and fields.
 
F

Frank Martin

Thanks. I'll change it to "people".
Regards, Frank




Sandra Daigle said:
Just one other thing to add to what Albert has said - you might want to
change your 'Name' field to something slightly different since Name is an
Access reserved word and a common property Name. Odd things can happen when
there are conflicts with Named properties and fields.

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Just build the combo box on the form using the wizard.

You can select the query you made for the source of this combo box.
You simply select the two fields. If the combo box wizard does NOT
hide the first column for you, then simply re-size it so small as to
hide the first column. The result will be a combo box that searches
and displays via the Name field, but in fact stores the NameID in the
field you bind the combo to.

So, give the wizard a try, it should build what you want with great
ease.

Also, to avoid confusing and problems, you at all costs avoid the
lookup feature in the table design mode...right?
 
F

Frank Martin

Thank you.

I am redesigning our application to convert all separate address tables into
one, via five new tables which are tblPeople, tblPeopleType, tblAddressName,
tblAddressType, and tblAddressDetail. From these we make one qryAddresses
and on this we base the frmAddress.

We had trouble when we used the FrmWizard to make the form
from the qryAddresses because the wizard based
the form on sql instead of the qryAddresses, and the combo box will not work
in this case. When we made the form manually from the qryAddresses the
combo wizard worked fine. I thought I should let you know about this.

Regards, Frank
 

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