Function updateAmountNew()
On Error GoTo erC
Dim db As Database
Dim rstOut As Recordset
Dim f As Field
Dim taw As String
Set db = CurrentDb
Set rstOut = CurrentDb.OpenRecordset("ตาราง/คิวรี่")
rstOut.MoveFirst
Do Until rstOut.EOF
If InStr(rstOut.Fields("DebitCredit").Value, "Credit") > 0 Then
taw = rstOut.Fields("Amount").Value
End If
For Each f In rstOut.Fields
DoCmd.SetWarnings False
rstOut.Edit
rstOut![AmountNew] = taw
rstOut.Update
Next
rstOut.MoveNext
If InStr(rstOut.Fields("DebitCredit").Value, "Credit") <= 0 Then
taw = taw
Else
taw = rstOut.Fields("Amount").Value
End If
Loop
rstOut.Close
Set db = Nothing
Exit Function
erC:
Select Case Err
Case 0
Case 3021
Exit Function
Case Else
MsgBox "Function updateAmountNew" & " > " & Err.Description & " รหัส " & Err.Number
End Select
End Function