更新访问查询

时间:2015-06-05 14:30:24

标签: ms-access access-vba ms-access-2010

我有大约40,000行,我正在尝试更新任何空白单元格 在Claim_Status_Data table的标题"UNKNOWN"或表Claim_Status的输出"Status"下。当我运行选择查询时,行数急剧缩减到20,000。问题是我需要所有40,000行。

IIf(IsNull([_DATA]![Claim_Status]),"UNKNOWN",[Status]![Claim_Status])

例如,

我有一行在_Data表的ehading Claim_Status下有一个null(空)单元格。当我运行查询时,我仍然应该将“UNKNOWN”添加到“Claim_Status”而不是空单元格中。

但是,当我运行查询时,该行消失,总行数降至约20,000。我猜测已经消失的行有类似的问题。

我正在为您的信息运行“选择”查询而不是“更新”查询。

此外,Claim_Status的输出不是来自_Data表的值,而是链接到它的那个。 _Data表中的Claim_Status列链接到名为“Status”的另一个表中的Data_Status_Type,输出是与Data_Status_Type中的值对应的任何内容。

这是导致整个问题的原因吗?

编)

SQL代码

   SELECT [_DATA].Claimant_Name, [_DATA].Account_ID, [_DATA].Claim_ID, [_DATA].Account_Name, [_DATA].Claim_Type, [_DATA].Coverage, [_DATA].Claim_Level, [_DATA].Claim_Count, [_DATA].File_Date, [_DATA].File_Year, [_DATA].Resolution_Date, [_DATA].Resolution_Year, Status.Claim_Status, [_DATA].Indemnity_Paid, Disease.Disease_Category, State.State_Filed, [_DATA].First_Exposure_Date, [_DATA].Last_Exposure_Date, [_DATA].Claimant_Employee, [_DATA].Claimant_DOB, [_DATA].Claimant_Deceased, [_DATA].Claimant_DOD, [_DATA].Claimant_Diagnosis_Date, [_DATA].Product_Type, [_DATA].Product_Line, [_DATA].[Company/Entity/PC], [Plaintiff Firm].Plaintiff_Law_Firm, [_DATA].Asbestos_Type, [_DATA].Evaluation_Date, [_DATA].Tier, [_DATA].Data_Source, [_DATA].Data_Source_Category, [_DATA].[Jurisdiction/County], [_DATA].Settlement_Demand, [_DATA].Jury_Verdict, [_DATA].Exposure_Site, [_DATA].National_Defendant_Firm, [_DATA].Local_Defendant_Firm, [_DATA].Expense_Amount, [_DATA].NCC_Expense_Amount, [_DATA].Non_NCC_Expense_Amount
FROM (((_DATA LEFT JOIN Disease ON [_DATA].Disease_Category = Disease.Data_Disease_Type) LEFT JOIN [Plaintiff Firm] ON [_DATA].Plaintiff_Law_Firm = [Plaintiff Firm].Data_Firm) LEFT JOIN State ON [_DATA].State_Filed = State.Data_State) LEFT JOIN Status ON [_DATA].Claim_Status = Status.Data_Status_Type
WHERE (((Status.Claim_Status)=IIf(IsNull([_DATA]![Claim_Status]),"UNKNOWN",[Status]![Claim_Status])));

1 个答案:

答案 0 :(得分:0)

如果我正确理解了您之后的内容,即从最左侧的表[_DATA]返回所有行,只需将[_DATA]![Claim_Status]中的NULL替换为" UNKNOWN&# 34;,然后您应该删除WHERE子句,并将该字段添加到SELECT函数(http://www.techonthenet.com/access/functions/advanced/nz.php)中的Nz语句中。以下是示例SQL:

 SELECT Nz([_DATA]![Claim_Status], "UNKNOWN") As [_DATA_Claim_Status], [_DATA].Claimant_Name, [_DATA].Account_ID, [_DATA].Claim_ID, [_DATA].Account_Name, [_DATA].Claim_Type, [_DATA].Coverage, [_DATA].Claim_Level, [_DATA].Claim_Count, [_DATA].File_Date, [_DATA].File_Year, [_DATA].Resolution_Date, [_DATA].Resolution_Year, Status.Claim_Status, [_DATA].Indemnity_Paid, Disease.Disease_Category, State.State_Filed, [_DATA].First_Exposure_Date, [_DATA].Last_Exposure_Date, [_DATA].Claimant_Employee, [_DATA].Claimant_DOB, [_DATA].Claimant_Deceased, [_DATA].Claimant_DOD, [_DATA].Claimant_Diagnosis_Date, [_DATA].Product_Type, [_DATA].Product_Line, [_DATA].[Company/Entity/PC], [Plaintiff Firm].Plaintiff_Law_Firm, [_DATA].Asbestos_Type, [_DATA].Evaluation_Date, [_DATA].Tier, [_DATA].Data_Source, [_DATA].Data_Source_Category, [_DATA].[Jurisdiction/County], [_DATA].Settlement_Demand, [_DATA].Jury_Verdict, [_DATA].Exposure_Site, [_DATA].National_Defendant_Firm, [_DATA].Local_Defendant_Firm, [_DATA].Expense_Amount, [_DATA].NCC_Expense_Amount, [_DATA].Non_NCC_Expense_Amount
 FROM (((_DATA LEFT JOIN Disease ON [_DATA].Disease_Category = Disease.Data_Disease_Type) LEFT JOIN [Plaintiff Firm] ON [_DATA].Plaintiff_Law_Firm = [Plaintiff Firm].Data_Firm) LEFT JOIN State ON [_DATA].State_Filed = State.Data_State) LEFT JOIN Status ON [_DATA].Claim_Status = Status.Data_Status_Type;

那个WHERE子句没有达到预期的效果,因为它说的是[_DATA]![Claim_Status]是否为Null然后返回行Status.Claim_Status =" UNKNOWN" ,否则返回Status.Claim_Status等于自己的行。而且,由于您在WHERE条款中包含外部联接表格,因此您可以有效地将其转换为INNER JOIN