메시지 상자에 값을 표시
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
이 내 작업 코드입니다!
'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
나는 당신이 with rs 문을 가지고 있고 그 후에도 여전히 rs를 사용하여 테이블을 참조합니다. 문제는 아니지만 오류가 발생하면 위치를 찾을 수 없으므로 항상 진술을 사용하지 마십시오. - 그런 다음 편집을 한 줄 아래로 이동하거나 편집하기 전에 val = 문을 이동하십시오. – Johanness
@Johanness에 동의하고'Val ='코드 아래에서'rs.Edit'을 이동하십시오. 시도해 봐. –