此代碼有錯誤「標準表達式中的數據類型不匹配」,我認爲這是因爲strDate和我的查詢中的數據QryStockRinci。錯誤「標準表達式中的數據類型不匹配」
Public Function ReturnAmountSaleRev(strDate As Date, strProductID As String, curAmount As Currency, curAmountSale As Currency) As Variant
Dim curAmountSaleUpToCurrentPO As Integer Dim varAmountSalePriorToCurrentPO As Variant 'Get the total Amount for the current ProductID up to and including given PO. curAmountSaleUpToCurrentPO = DSum("Stock", "QryStockRinci", "[Tanggal] <= '" & strDate & "' AND [kode_barcode] = '" & strProductID & "'") 'If there is enough in SalesAmount to cover the whole cost, return the whole Amount. If curAmountSale - curAmountSaleUpToCurrentPO >= 0 Then ReturnAmountSaleRev = Format(curAmount, "0.00") Else 'Get the the total Amount in ProductID prior to current PO. varAmountSalePriorToCurrentPO = DSum("Stock", "QryStockRinci", "[Tanggal] < '" & strDate & "' AND [kode_barcode] = '" & strProductID & "'") 'If current PO is first in ProductID, varAmountSalePriorToCurrentPO will be null; 'determine covered amount. If IsNull(varAmountSalePriorToCurrentPO) = True Then If curAmount <= curAmountSale Then ReturnAmountSaleRev = Format(curAmount, "0.00") Else ReturnAmountSaleRev = Format(curAmountSale, "0.00") End If Else 'If current PO is not first in ProductID, varAmountSalePriorToCurrentPO 'will have a value; determine the covered amount. varAmountSalePriorToCurrentPO = curAmountSale - varAmountSalePriorToCurrentPO If varAmountSalePriorToCurrentPO <= 0 Then ReturnAmountSaleRev = 0 Else ReturnAmountSaleRev = Format(varAmountSalePriorToCurrentPO, "0.00") End If End If End If
端功能
你能告訴我們哪一行是錯誤嗎? – PaulFrancis
curAmountSaleUpToCurrentPO = DSum(「Stock」,「QryStockRinci」,「[Tanggal] <='」&strDate&「'AND [kode_barcode] ='」&strProductID&「'」) –