使用DLookup和组合框选择

时间:2017-11-16 16:11:10

标签: vba ms-access

我一直在

  

数据类型不匹配

当我使用代码时,我读了另一篇文章。我将发布我尝试过的每个变体,我需要这个变量来查询摘要查询中的值,所以当你尝试在低价时进行交易时,它会显示弹出窗口,说明你的股票价格很低。

下面的第一次尝试会返回数据不匹配。

Private Sub cboTransactionItem_AfterUpdate()

Dim Restock As Variant
Dim ReorderAmount As Variant

ReorderAmount = DLookup("'[Reorder Amount]'", "ReorderingStock", "[Transaction Item] = '" & Me!cboTransactionItem.Text & "'")
Restock = DLookup([True Stock], "ReorderingStock", "[Transaction Item] = '" & Me!cboTransactionItem.Text & "'")

If Restock < ReorderAmount Then
MsgBox "Stock is Low"
Else
End If

End Sub

我尝试了第二次尝试

Private Sub cboTransactionItem_AfterUpdate()

Dim Restock As Variant
Dim ReorderAmount As Variant

ReorderAmount = DLookup("'[Reorder Amount]'", "ReorderingStock", "[Transaction Item] = '" & Me!cboTransactionItem.Value & "'")
Restock = DLookup([True Stock], "ReorderingStock", "[Transaction Item] = '" & Me!cboTransactionItem.Value & "'")

If Restock < ReorderAmount Then
MsgBox "Stock is Low"
Else
End If

End Sub

如果有人可以提供帮助,这些都不起作用我会很感激......

0 个答案:

没有答案