开发者

Access 2007 - Display text fields in drop down list while bundling to an ID

开发者 https://www.devze.com 2023-01-02 10:41 出处:网络
in Access 2007 how can I display text fields in drop down list while bundling to an ID? not while selecting (we can do this by plying with the width field. but what I need after s开发者_如何学JAVAelec

in Access 2007 how can I display text fields in drop down list while bundling to an ID? not while selecting (we can do this by plying with the width field. but what I need after s开发者_如何学JAVAelecting?

Do we create a hidden field that stores the ID?


Your description of how a combo box works is correct. Keep in mind that while you're setting the first column and display length to zero, that means the combo box will then search by the second text column. The combo box will display by that second text column after you select a value. In fact in all cases for typing in a value, even partial matching as you type, a simple select of a value will ALL BE done by the displayed text column but in ALL CASES it will save the actual ID (the first column) into the table that the form is bound to.

So no additional coding or anything if need be done on your part to achieve the above goal and in fact this is pretty much the default as to how combo boxes work inside of ms access.

What makes the combo box is somewhat unique inside of Access is you can have more then 2 columns. And, in the combo box settins you can choose what column is to be selected and saved into the table. And, the combo box has both before update (with a cancel), and after update and also a Not in List event that fires in the case of a user tyring to type in a value that not in the list.

So, the Access combo box is quite flexible. The source for the list or members displayed in the combo box can be based on a table, on a query, or you can even type in a value list that is saved inside of the property sheet. And, another option is to fill the combo box is by using call backs (so, again quite a few ways to fill out the list of memebers for selectiogn).

So, keep in mind there is two aspects to the combo box. There's a so called row data source or how you feed the members that will display in the combo box. Then there is the underlying column (field) that you bind that control to when you select a value. That is in the case when the combo box is bound.

As mentioned, the bound column setting is another property in terms of inside the combo box, and you don't need to write any additional code to achieve that above goal in your question.


Albert Thank you for this excellent explanation.

I found out that the bound column has no effect. Acces take the first visible field and bound to it regardless of what you have in the bound column property.

All good thanks

Omar ( hostitwise.com)

0

精彩评论

暂无评论...
验证码 换一张
取 消