是否将默认值分配给Microsoft Access表字段? [英] Assigning a default value to a Microsoft Access Table Field?
问题描述
我在Microsoft Access中有一个数据库表.我想将其中一个字段的默认值分配给同一表中较早出现的另一个字段.
I have a database table in Microsoft Access. I want to assign the default value of one of those fields to another field that happens earlier in the same table.
我尝试的值=[Form1].[AssignedByes]
没有运气,而=[AssignedByes]
却没有运气.
I tried the value =[Form1].[AssignedByes]
with no luck and the same for =[AssignedByes]
but with no luck.
任何人都可以帮忙吗?
我为其分配值的字段名称为[RemainingByes]
,而为其分配值的字段名称为[AssignedByes]
.
The field name I'm assigning the value to is [RemainingByes]
and the field that assigning the value of is [AssignedByes]
.
推荐答案
为解决此问题,我创建了一个基本上用作表的查询.创建其他查询,表单等时,我使用它而不是表格.
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]
这篇关于是否将默认值分配给Microsoft Access表字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!