1

我正在使用 MS Access 2007。

我在数据库中有一个表,关注的 3 个字段是:

字段 1 = 打开日期位置(日期)

字段 2 = 日期位置关闭(日期)

字段 3 = 状态(文本)

我需要有关以下最佳方法的指导:

在表单输入级别,只要用户在日期位置打开字段中输入日期,状态字段就会更改以在其字段中显示文本“活动”。

一旦用户在日期位置关闭字段中输入日期,状态字段就会从“活动”变为“非活动”。

这发生在添加到表中的每条记录上。

我在表级别玩过各种验证规则,希望在创建表单之前有一个规则或表达式。那没有用,我认为它是在表单级别,也许答案是这样的:

Ms Access 1 字段触发另一个字段的数据

或者我应该看看生成声明 2 个字符串“Active”和“Inactive”然后使用 IF Date Location open has Date value 然后将“Active”字符串添加到字段的代码。

还是我忽略了显而易见的东西,它就像一个组合框一样简单......

4

1 回答 1

1

Use the after update event of the "date opened" text box to set the value of the "status" text box. If that text box is named "txtStatus", a simple assignment statement could be:

Me.txtStatus = "Active"

However, you might want to first verify "date closed" is Null. Otherwise, an "Inactive" record would be set as "Active" again if a user subsequently changes the "date opened" value.

Also consider whether Null is to be permitted for "date opened" and what should happen if an existing value is changed to Null.

Similarly, use the after update event of the "date closed" text box to adjust the value of txtStatus. However, the logic there will likely differ from that of the "date opened" after update event.

于 2012-10-13T04:44:55.973 回答