hi! im making an inventory in access 2007. i created a macro in vba that would check if there is an existing record based on the form information. i want the opening balance to carry over the ending balance. now, the problem comes in.
1. the ending balance does not display on the forms opening balance
2. if there are multiple items that meet the criterias, i should sort the dates and get the closest to the most recent date.
heres my code so far. (ps.im just a newbie)
With a
Do Until .EOF
For Each flddist In .Fields
If flddist.Name = "Dist/Customer" Then
If flddist.Value = b![Dist/Customer] Then
For Each fldbranch In .Fields
If fldbranch.Name = "Branch" Then
If fldbranch.Value = b!Branch Then
For Each fldItem In .Fields
If fldItem.Name = "ItemDescription" Then
If fldItem.Value = b![ItemDescription] Then
For Each flddate In .Fields
If flddate.Name = "Date Received/dispatched" Then
'insert choose the most recent entry
For Each fldending In .Fields
If fldending.Name = "EndingBalance" Then
b![BegBalance] = fldending.Value
MsgBox "found"
Exit For
End If
Next
End If
Next
End If
End If
Next
End If
End If
Next
Exit For
End If
Else
b![BegBalance] = 0
End If
Next
.MoveNext
Loop
End With
Exit Sub
BegBalance_Error:
MsgBox "An error has occured"
End Sub
opinions are very much welcome. Thanks guys!