I am attempting to set the value of a combo box from a "Splash Screen" type form in Access that will take the user's computer name and load two combo boxes on another form with the Employee ID and Manager ID, which are both bound columns of the combo boxes, which are unbound themselves. I can get the IDs in the combo box, but i want it to still display column 2 (Names) of both combo boxes. Right now it just displays the IDs. Anyone got any ideas how i can get it to react like i actually picked it in the combo box?
我试图在Access中的“启动画面”类型窗体中设置组合框的值,该窗体将获取用户的计算机名称并在另一个窗体上加载两个组合框,其中包含Employee ID和Manager ID,这两个组合框都是组合框,它们自己没有绑定。我可以在组合框中获取ID,但我希望它仍然显示两个组合框的第2列(名称)。现在它只显示ID。任何人有任何想法我怎么能让它做出反应,就像我在组合框中实际选择它一样?
1 个解决方案
#1
So, comboboxes can sometimes be tricky, but once you get it down you should be good to go.
因此,组合框有时候会很棘手,但是一旦你把它弄下来就应该很好。
So, when looking at a Combobox's properties, The Format
tab :
因此,在查看Combobox的属性时,“格式”选项卡:
ColumnCount: 2 <-- You want the ID and the Name
ColumnWidths: 0";1" <--- You're hiding the ID field, which is the first column
The data
tab: This is where you're going to tell Access what data you're supplying for your combobox.
数据选项卡:您可以在此处告知Access您为组合框提供的数据。
Usually it's a query or table data source. If it's a query you should be selecting the ID
and Name
fields, and use that query in the RowSource
property in the Data
tab.
通常它是查询或表数据源。如果是查询,则应选择ID和Name字段,并在Data选项卡的RowSource属性中使用该查询。
Row Source: Select ID, Name FROM YourTable
Row Source Type: Table/Query
When you use the Wizard to create the combobox, it's fairly straightforward. When Access asks you to format your data source, you completely shrink the ID
column, so it hides it (but it's still there).
当您使用向导创建组合框时,它非常简单。当Access要求您格式化数据源时,您会完全缩小ID列,因此它会隐藏它(但它仍然存在)。
The steps would be:
步骤将是:
- I want the combobox to look up the values in a table or query
- Select the Table or Query
- Select the Fields (ID and Name seem appropriate for your scenario)
- Any sorting you may want
- The next screen is where we want to hide our
ID
column, so shrink it entirely - The next screen is where we tell Access that we want the
ID
to be in scope (selected) when we select a combobox item - Name it & be proud
我希望组合框在表或查询中查找值
选择表或查询
选择字段(ID和名称似乎适合您的方案)
你可能想要的任何排序
下一个屏幕是我们要隐藏ID列的位置,因此完全缩小它
下一个屏幕是我们告诉Access我们在选择组合框项目时希望ID在范围(选定)中的位置
说出来并感到自豪
#1
So, comboboxes can sometimes be tricky, but once you get it down you should be good to go.
因此,组合框有时候会很棘手,但是一旦你把它弄下来就应该很好。
So, when looking at a Combobox's properties, The Format
tab :
因此,在查看Combobox的属性时,“格式”选项卡:
ColumnCount: 2 <-- You want the ID and the Name
ColumnWidths: 0";1" <--- You're hiding the ID field, which is the first column
The data
tab: This is where you're going to tell Access what data you're supplying for your combobox.
数据选项卡:您可以在此处告知Access您为组合框提供的数据。
Usually it's a query or table data source. If it's a query you should be selecting the ID
and Name
fields, and use that query in the RowSource
property in the Data
tab.
通常它是查询或表数据源。如果是查询,则应选择ID和Name字段,并在Data选项卡的RowSource属性中使用该查询。
Row Source: Select ID, Name FROM YourTable
Row Source Type: Table/Query
When you use the Wizard to create the combobox, it's fairly straightforward. When Access asks you to format your data source, you completely shrink the ID
column, so it hides it (but it's still there).
当您使用向导创建组合框时,它非常简单。当Access要求您格式化数据源时,您会完全缩小ID列,因此它会隐藏它(但它仍然存在)。
The steps would be:
步骤将是:
- I want the combobox to look up the values in a table or query
- Select the Table or Query
- Select the Fields (ID and Name seem appropriate for your scenario)
- Any sorting you may want
- The next screen is where we want to hide our
ID
column, so shrink it entirely - The next screen is where we tell Access that we want the
ID
to be in scope (selected) when we select a combobox item - Name it & be proud
我希望组合框在表或查询中查找值
选择表或查询
选择字段(ID和名称似乎适合您的方案)
你可能想要的任何排序
下一个屏幕是我们要隐藏ID列的位置,因此完全缩小它
下一个屏幕是我们告诉Access我们在选择组合框项目时希望ID在范围(选定)中的位置
说出来并感到自豪