MS Access: Display two columns in combo-box

谁说胖子不能爱 提交于 2019-12-22 05:21:49

问题


Embarrassingly simple question but I can't work it out or find the answer via google.

Got something like this with two colums

But when selected it only displays one column, making the information much harder to read/ understand.

Tried changing properties in property sheet (such as column number) but to no apparent effect.


回答1:


It depends to a certain extent on what you are doing, often something like this suits:

SELECT Id, Surname & ", " & Forename from Table

In other words, the bound column is a unique ID and the selection column includes both the surname and forename in a single column.

EDIT based on additional information:

SELECT [Contact].[CID], [Contact].[Csname] & ", " & [Contact].[Cfname] 
FROM [Contact] ORDER BY [CID], [Csname], [Cfname];



回答2:


Since my first column is used to group items in the second it didn't look nice to just separate them using

SELECT ID, [Type] & ": " & [Title] AS BothValues

as suggested. With a lot of items the dropdown looks confusing like in this example.

I found out that Access seems to display the first (technically) visible column in the combobox after a selection has been made. Therefore I ended up using

SELECT ID, [Type] & ": " & [Title] AS BothValues, Type, Title

and setting the width of the second column to the smallest possible, de facto invisible value (0";0.007";1",1"). Don't forget to raise the column count (4). Now the dropdown appears grouped, but I still get both information after the selection.



来源:https://stackoverflow.com/questions/11762395/ms-access-display-two-columns-in-combo-box

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!