[英]looping through recordset in access
Im trying to get a recordset loop code working, i have my bellow code which keeps inputing a zero. 我试图使一个记录集循环代码工作,我有我的波纹管代码,不断输入零。 My second piece of code is identical code but displaying the qty in a message box.
我的第二段代码是相同的代码,但是在消息框中显示了数量。 The number it is displaying is the number i want to input into my field.
它显示的数字是我想输入到我的字段中的数字。 I just cant seem to get it to put the number in the field !Qty?
我似乎无法将数字输入字段!数量?
Dim Val As Integer
Dim rs As DAO.Recordset
Set rs = Forms!frmReceive!sfrmReceiveDetailEntry.Form.RecordsetClone
With rs
Do While Not rs.EOF
rs.Edit
Val = Nz(DLookup("[RemainingQty]", "tblQtySoFarTEMP", "[OrderDetailPK]= " & rs! [OrderDetailFK]))
rs!Qty = Val
rs.Update
rs.MoveNext
Loop
End With
Set rs = Nothing
Displaying value in message box 在消息框中显示值
Dim val As Integer
Dim rs As DAO.Recordset
Set rs = Forms!frmReceive!sfrmReceiveDetailEntry.Form.RecordsetClone
With rs
Do While Not rs.EOF
val = Nz(DLookup("[RemainingQty]", "tblQtySoFarTEMP", "[OrderDetailPK]= " & rs! [OrderDetailFK]))
MsgBox val
rs.MoveNext
Loop
End With
Set rs = Nothing
I worked it out in the end, this is my working code! 我终于解决了,这是我的工作代码!
'If YES then run the following code
AreYouSure = MsgBox("You are about to Receive All of Order" & txtOrderNumber.Value & " , Are you Sure?, The whole order and it's Quantities will be updated?", vbYesNo, "Receive All?")
If (AreYouSure = vbYes) Then
'disable warnings
DoCmd.SetWarnings False
'Create recordsetclone of subform
'loop recordset and lookup remaining qty to receive all
Set rs = Forms!frmReceive!sfrmReceiveDetailEntry.Form.RecordsetClone
With rs
Do While Not rs.EOF
rs.Edit
rs("Qty") = Nz(DLookup("[RemainingQty]", "tblQtySoFarTEMP", "[OrderDetailPK]= " & rs![OrderDetailFK]))
rs.Update
rs.MoveNext
Loop
End With
Set rs = Nothing
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.