且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

是否将默认值分配给Microsoft Access表字段?

更新时间:2023-02-11 19:52:07

为解决此问题,我创建了一个基本上用作表的查询.创建其他查询,表单等时,我使用它而不是表格.

To get around this problem, I create a Query that basically functions as the table. I use it instead of the table when creating other queries, forms, etc.

我猜您将[AssignedByes]复制到[RemainingByes],因为[RemainingByes]将从[AssignedByes]的值开始,但是您希望以后可以更改它.

I'm guessing that you copy [AssignedByes] into [RemainingByes], because [RemainingByes] will start off with the value of [AssignedByes], but you want to be able to change it later.

因此,您可以使用称为[xRemaningByes]的计算字段来设置查询.您将在[RemainingByes]中输入更改的值.然后在[xRemainingByes]中设置一个公式,如果有则返回[RemainingByes]的值,否则返回[AssignedByes]的值.

So, you can set up the Query with a calcualted field called [xRemaningByes]. You would enter the changed values in [RemainingByes]. Then set up a formulat in [xRemainingByes] that returns the value of [RemainingByes] if there is one, and it not, it returns the value of [AssignedByes].

[xRemainingByes]:Iif([IsNull([RemainingByes],[AssignedByes],[RemainingByes].

[xRemainingByes]: Iif([IsNull([RemainingByes],[AssignedByes], [RemainingByes].

使用查询而不是表时,将使用[xRemainingByes](它是查询的计算字段),而不是表的字段[RemainingByes].


另一个选项---
在表中创建一个字段,例如[RemainingByesOverride],这将是您难以输入更改数据的地方.然后,删除表中的[RemainingByes],仅在查询中将其作为计算字段.

When you use the Query instead of the Table, you will use [xRemainingByes], which is the Query's calculated field, instead of the Table's field [RemainingByes].


ANOTHER OPTION ---
Create a field in the Table such as [RemainingByesOverride], and that would be where you hard enter the changing data. Then get rid of [RemainingByes] in the table and only have it in the Query as a calculated field.

[xRemainingByes]:Iif([IsNull([RemainingByesOverride],[AssignedByes],[RemainingByesOverride]

[xRemainingByes]: Iif([IsNull([RemainingByesOverride],[AssignedByes], [RemainingByesOverride]