【问题标题】:check with vba rows in a table meeting a certain condition检查满足特定条件的表中的 vba 行
【发布时间】:2019-08-15 20:16:31
【问题描述】:

我刚开始使用 VBA,我有一个表,我想搜索满足条件的记录:装运是相同的,有足够的库存,如果这是真的,那么我想每行更改 table_field complete_order为真。 如果有足够的库存,我已经将字段 complete_line 更改为 true。但我不能得到它的总出货量。希望有人可以帮助我。

为了更改字段 complete_line,我使用了这段代码,它运行良好。:

Dim rs As DAO.Recordset

Set rs = CurrentDb.OpenRecordset("SELECT * FROM hal_b_prep")

If Not (rs.EOF And rs.BOF) Then
rs.MoveFirst 'Unnecessary in this case.
Do Until rs.EOF = True
If rs!test.P <> "C" Then 'checking if shipment line is not completed yet
    If rs!SumOfav_stock > rs!test.qty Then

        rs.Edit
        rs!test.complete_line = True
        rs.Update
    End If
    End If
    'Move to the next record. 
    rs.MoveNext
Loop
 Else
 MsgBox "There are no records in the recordset."
 End If

 MsgBox "Finished looping through records."

 rs.Close 'Close the recordset
 Set rs = Nothing 'Clean up` 

【问题讨论】:

  • 我想从表格中发布一张带有数据的图片,但我不知道怎么做?我尝试了几个领域,但我不允许发布这个?
  • 不要使用图片提供数据!见minimal reproducible example!

标签: ms-access-2016


【解决方案1】:

您没有列出该字段,但它可能是这样的:

If rs!SumOfav_stock > rs!test.qty Then
    rs.Edit
        rs!test.complete_line.Value = True
        rs!test.total.Value = rs!test.total.Value + DeliveredQuantity
    rs.Update
End If

【讨论】:

    猜你喜欢
    • 2018-05-21
    • 1970-01-01
    • 2021-05-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-12
    • 1970-01-01
    • 2016-05-09
    相关资源
    最近更新 更多