从表中读取数据(MS Access 新手)

发布于 2024-08-18 17:08:10 字数 440 浏览 6 评论 0原文

我意识到这个问题很新手,但谷歌搜索对我没有帮助。

我创建了一个 MS Access 数据库,并尝试在使用下拉菜单中的数据更新另一个单元格时自动更新一行中的一个单元格。我已经为表单中的文本框创建了一个子“afterupdate”,并且可以简单地创建一个“选择案例”来根据输入的值更新单元格。

但是,选择案例会很长,而且我已经在数据库的另一个表中填充了值列表。有没有办法将新单元格的值设置为相应的值?

示例:

表 1:

模式 --- 时间

A --------- 1:00

B --------- 2:00

C ------ --- 4:00

因此,在我的表单中,当我为一个单元格选择“A”时,另一个单元格将自动更新信息“1:00”。同样,“选择案例”有效,我想知道是否有更快的方法。

I realize the newbieness of this question, but google searches are not helping me.

I've created an MS Access database and am trying to automatically update a cell in a row when another cell is updated with data from a drop-down menu. I've created a sub "afterupdate" for the text box in the form, and can simply create a "select case" to update the cell based on what value is entered.

However, the Select Case would be very long, and I already have the list of values populated in another table in the database. Is there a way to set the value of the new cell to whatever the corresponding value is?

Example:

Table 1:

Mode --- Time

A --------- 1:00

B --------- 2:00

C --------- 4:00

So, in my form, when I select "A" for one cell, another cell would automatically update with the information "1:00". Again, "Select Case" works, I am wondering if there is a faster way.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

長街聽風 2024-08-25 17:08:10

如果您希望在表单中执行此操作,请尝试

  • 使用名为的组合框创建一个表单
    cmb模式
  • 关于属性/数据更改
    行源SELECT * FROM tblModes
  • 关于属性/格式更改
    列数更改为 2。
  • 属性/格式更改
    列宽为 3,0
  • 创建一个名为 txtTime 的文本框。
  • 关于属性/数据更改
    控制源 =[cmbMode].[Column] (1)。

这应该会在更改时自动更新。

编辑

事后想想,这不会将值更新到表中,因为文本框不会绑定到字段。

您可以更改组合框 AFTER_UPDATE 事件使用(如果文本框绑定到TIME字段)使用

Time.Value = cmbMode.Column(1)

If you wish to do this in a form, lets try

  • Create a form with a combo box called
    cmbMode.
  • On the Properties/Data change
    Row Source to SELECT * FROM tblModes.
  • On the Properties/Format change
    Column Count to 2.
  • On the Propeties/Format change
    Column Widths to 3,0
  • Create a Text box called txtTime.
  • On the Properties/Data change
    Control Source to =[cmbMode].[Column] (1).

That should auto update on change.

EDIT

Just as an after thought, this will not update values to a table, as the text box will not be bound to a field.

You could change the combo box AFTER_UPDATE event to use (if the textbox is bound to the TIME field) to use

Time.Value = cmbMode.Column(1)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文