【问题标题】:Validate multiple textboxes with two values to summarize report使用两个值验证多个文本框以汇总报告
【发布时间】:2019-07-07 12:57:31
【问题描述】:

对于我们的机器,我们有多个验证阶段。每个阶段都需要“OK”或“N/A”才能将机器发送给客户。我有多个文本框,它们填写特定阶段是“OK”还是“NOK”(不是 oke)还是“N/A”。

如果一切都“OK”或“N/A”那么MouldTotal.value="OK" Else MouldTotal.value="NOK"

我无法让它工作,也没有找到适用于这种情况的方法。

提前感谢您的帮助。

对于下面的第一个代码,我收到了错误 13 类型匹配。

If DryCycle_status.Value = "OK" Or "N/A" And Temp_status = "OK" Or "N/A" And _ 
BackPressure_status.Value = "OK" Or "N/A" And _
Filling_status = "OK" Or "N/A" And Injection_status.Value = "OK" Or "N/A" _ 
And HoldingPressure_status = "OK" Or "N/A" _
And CoolingTime_status.Value = "OK" Or "N/A" And ClampingForce_status = "OK" Or "N/A" And _
ProcessStability_status.Value = "OK" Or "N/A" And AdditionalTesting_status = "OK" Or "N/A" _
Then MouldTotal.Value = "OK" Else MouldTotal.Value = "NOK"

我也试过下面的代码。这个没有导致错误,但也没有对代码做任何事情。它似乎只是读取了MouldTotal 的值。

编辑;它似乎只读取DryCycle_status,因为当我将其更改为“NOK”时,MouldTotal 确实更改为“NOK”。当我更改任何其他“状态”时,它不会影响MouldTotal

If DryCycle_status.Value = "OK" Or DryCycle_status.Value = "N/A" And _
Temp_status = "OK" Or Temp_status.Value = "N/A" And _
BackPressure_status.Value = "OK" Or BackPressure_status.Value = "N/A" And _
Filling_status = "OK" Or Filling_status.Value = "N/A" And _
Injection_status.Value = "OK" Or Injection_status.Value = "N/A" And _
HoldingPressure_status = "OK" Or _
HoldingPressure_status.Value = "N/A" And CoolingTime_status.Value = "OK" Or _
CoolingTime_status.Value = "N/A" And ClampingForce_status = "OK" Or _
ClampingForce_status.Value = "N/A" And _
ProcessStability_status.Value = "OK" Or ProcessStability_status.Value =  "N/A" _
And AdditionalTesting_status = "OK" Or AdditionalTesting_status.Value  = "N/A" _
Then MouldTotal.Value = "OK" Else MouldTotal.Value = "NOK"

【问题讨论】:

  • 不幸的是,您没有提供有关 HOW 它“不起作用”的详细信息。这使得故障排除非常困难。但 FWIW 一目了然......这个公式If DryCycle_status.Value = "OK" Or "N/A" 在 VBA 中是不允许的。它必须是If DryCycle_status.Value = "OK" Or DryCycle_status.Value = "N/A" - 必须用每个比较运算符说明比较的双方 - 没有捷径。
  • @CindyMeister;抱歉,我没有详细说明为什么它不起作用。我收到了Error 13 type match。我也尝试过您建议的方式(我将编辑到原始帖子中。

标签: vba if-statement ms-word


【解决方案1】:

我想出了一个解决方法。它不漂亮,但对我有用。只要有 1 个或多个 "NOK" 或空白字段 "",我希望摘要显示 "NOK"。这就是下面的代码为我所做的。

If DryCycle_status.Value = "NOK" Or Temp_status = "NOK" Or BackPressure_status.Value = "NOK" Or _
Filling_status = "NOK" Or Injection_status.Value = "NOK" Or HoldingPressure_status "NOK" _
Or CoolingTime_status.Value = "NOK" Or ClampingForce_status = "NOK" Or _
ProcessStability_status.Value = "NOK" Or AdditionalTesting_status = "NOK" _
DryCycle_status.Value = "" Or Temp_status = "" Or BackPressure_status.Value = "" Or _
Filling_status = "" Or Injection_status.Value = "" Or HoldingPressure_status = "" _
Or CoolingTime_status.Value = "" Or ClampingForce_status = "" Or _
ProcessStability_status.Value = "" Or AdditionalTesting_status = "" Then 
MouldTotal.Value = "NOK" Else MouldTotal.Value = "OK"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-23
    相关资源
    最近更新 更多