I am trying to basically take a copy of one table and add it to a pre-existing table. For some reason I can not get my loop to work right. It simply goes through and copies the same record for each line. It puts in the right number, but never changes value. I would appreciate input on what might be wrong.
THANKS!
Code:
Do Until rstProductionReporting.EOF = True
IsNull (varCheck)
varCheck = DLookup("[id]", "Production Records", "mvt = " & Me.Mvt & " and material = '" & Me.Material & "' and quantity = " & Me.Quantity)
If Not IsNull(varCheck) Then
If varCount = 1 Then
varANS = Msgbox("This action will creat duplicate records. Continue?", vbYesNo)
End If
If varANS = True Then
rstProductionRecords.AddNew
rstProductionRecords!Mvt = Me.Mvt
rstProductionRecords!Material = Me.Material
rstProductionRecords![Old matl] = Me.[Old matl]
rstProductionRecords![Material desc] = Me.[Material desc]
rstProductionRecords![Post date] = Me.[Post date]
rstProductionRecords!Quantity = Me.Quantity
rstProductionRecords.Update
End If
Else
rstProductionRecords.AddNew
rstProductionRecords!Mvt = Me.Mvt
rstProductionRecords!Material = Me.Material
rstProductionRecords![Old matl] = Me.[Old matl]
rstProductionRecords![Material desc] = Me.[Material desc]
rstProductionRecords![Post date] = Me.[Post date]
rstProductionRecords!Quantity = Me.Quantity
rstProductionRecords.Update
End If
varCount = varCount + 1
rstProductionReporting.MoveNext
Loop
THANKS!