MS Access 数据表视图中的组合框数据输入
我需要帮助在 MS Access 2007 中创建我的第一个应用程序。
考虑 MS Access 中的一个表,其中包含“AgeGroup”列,该列的可能值为“Child”和“Adult”。 MS Access 中是否有一个选项可以使用组合框在数据表视图中使用这两个值将数据输入到此列中?
I need help in creating my first application in MS Access 2007.
Consider a table in MS Access with a column "AgeGroup" and the possible values for this column are "Child" and "Adult". Is there an option in MS Access to enter data into this column using a combo-box with these two values in Datasheet view?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
简单(但有问题)的解决方案:
(严格按照OP的问题)
文本
类型。Lookup
选项卡页Display Control
从TextBox
更改为< code>组合框行源类型
=值列表
行源
输入以下内容:Child,Adult< /code>
由于您可能希望利用 MS Access 是一个关系数据库这一事实,因此您还可以将
Child
和Adult
替代项作为单独中的行。代码>年龄类别表。为了将此表中的行与组合框连接起来,您必须使用其他查找设置。我把这个留给你作为练习。
编辑:正如 HansUp 所指出的,定义此组合框查找以及表定义确实不是一个很好的解决方案。
对于现实世界的解决方案来说,这可能是更好的方法:
数据表视图
中的表单看起来与双击表时获得的行编辑器类型完全相同。The Simple (but questionable) solution:
(in strict accordance with OP's question)
Text
type.Lookup
tab page in the MS Access table designerDisplay Control
fromTextBox
toCombo Box
Row Source Type
=Value List
Row Source
:Child,Adult
Since you probably want to leverage the fact that MS Access is a relational database, you could also have the have the
Child
andAdult
alternatives as rows in a separateAgeCategory
table. In order to connect the rows in this table with your combo box you would have to use other Lookup settings. This I leave as an excercise to you.EDIT: As HansUp is pointing out, it is really not a very good solution define this combo box lookup along with the table definition.
This is probably a better approach for a real world solution:
Datasheet View
. A form inDatasheet View
looks exactly like the type of row editor which you get when you double-click on a table.阅读表中查找字段的邪恶
而不是在表中创建邪恶的查找字段,构建一个使用该表(或基于该表的查询)作为该表单的记录源的表单。
将组合框添加到表单中。使用值列表或另一个查询作为组合的行源。将窗体切换到数据表视图。您还可以在表单的属性表上为“默认视图”选择数据表。
Read The Evils of Lookup Fields in Tables
Instead of creating an evil lookup field in your table, build a form which uses the table (or a query based on the table) as the form's record source.
Add your combo box to the form. Use a value list or another query as the combo's row source. Switch the form to datasheet view. You can also select datasheet for "Default View" on the form's property sheet.