此讨论于2011年7月29日开始(Fifo和Lifo成本计算方法,FIFO确定,LIFO问题)。我是MS Access的新手,希望有人可以帮我提供 先生的表格/表格字段名称。 Larocque 代码。
This discussion was started back in July 29, 2011 (Fifo and Lifo costing method, FIFO ok, LIFO problem). I am new to MS Access and was hoping someone could help me with the table / form field names from Mr. Larocque code.
以下是代码:
Option Compare Database Public Sub CalculateFifoStock() Dim cn As ADODB.Connection Dim Rs1 As ADODB.Recordset Dim Rs2 As ADODB.Recordset Dim Prid As Long Dim iTot As Long Prid = 0 iTot = 0 DelFifo ' check sub procedure below Set cn = CurrentProject.Connection Set Rs1 = New ADODB.Recordset Set Rs2 = New ADODB.Recordset Rs1.Open "zxFifo", cn, adOpenForwardOnly, adLockReadOnly Rs2.Open "FifoStock", cn, adOpenDynamic, adLockOptimistic Do While Not Rs1.EOF If Rs1![prd] = Prid Then iTot = iTot + Rs1![pr] Else Prid = Rs1![prd] iTot = Rs1![pr] End If If iTot <= Rs1!sold Then Else 'if total quantity purchased does not exceed consumed Rs2.AddNew ' *********************** Assign purchase details Rs2!fdate = Rs1!xdate Rs2!doc = Rs1!doct Rs2!prdt = Rs1!prd Rs2!PQty = Rs1!pr Rs2!RQty = iTot Rs2!Rt = Rs1!Pp ' *********************** Assign available quantity If iTot - Rs1!sold > Rs1!pr Then Rs2!avQty = Rs1!pr Else Rs2!avQty = iTot - Rs1!sold End If ' *********************** Rs2.Update End If Rs1.MoveNext Loop Rs1.Close Rs2.Close cn.Close Set Rs1 = Nothing Set Rs2 = Nothing Set cn = Nothing End Sub Private Sub DelFifo() CurrentDb.Execute "delete * from fifoStock", dbFailOnError ' to empty table before new insertion End Sub
推荐答案
你好Bradyman
Hi Bradyman
你的问题有点模糊。
You question is a little vague.
RecordSets Rs1和Rs2来自一个名为 " zxFifo"和 FifoStock" 。
The RecordSets Rs1 and Rs2 come from a tables or queries named"zxFifo" and "FifoStock"respectively.
字段名称前面加上"!"。 ,so Rs1!xdate 指表/查询zxFifo和字段xdate。
The Field names are listed preceeded by a"!" , soRs1!xdateRefers to Table/Query zxFifo and field xdate.
更多推荐
Fifo成本计算方法
发布评论