I'm trying to select pairs of records. One is the original transaction, the other is its reversal. So, the only difference between the two records is the amount: one is a positive value the other is its negative value
- loop through a DAO recordset to find a negative amount
- When found, find the original transaction using findrvrs(), mark it
The above works but the results are inconsistent. See URL below to image file. The records marked in green is where the code works. Those in red should have worked, but didn't.
- Before this I tried DAO Find/Update same results.
- Tried closing Access completely and trying again, no luck.
- Does not work on the same records.
- loop through a DAO recordset to find a negative amount
Code:
Do
misvar = False
misvar = chkmisvar() 'checks for missing info
badDate = False
badDate = chkbadDate(#1/1/2008#) 'transactions before 2008
If cr(14) < 0 Then 'reversed transaction
markProcessed (17) 'mark as invalid record
misc = findrvrs() 'find reversed record
cr.MoveNext
- When found, find the original transaction using findrvrs(), mark it
Code:
Public Function findrvrs() As Boolean
Dim strWhere As String
Dim strUpdate As String
Dim strSQLQuery As String
amt = -1 * cr(14) 'set amount to positive
'famt = Format(amt, "#,##0.00")
strUpdate = "UPDATE [" & tripDBName & "] SET [" & tripDBName & "].Processed = 1"
strWhere = " Where [" & tripDBName & "].HCP = " & cr(4) & " AND " & _
"[" & tripDBName & "].Departure = #" & cr(5) & "# And " & _
"[" & tripDBName & "].Origin LIKE " & Chr(34) & cr(7) & Chr(34) & " And " & _
"[" & tripDBName & "].Destination LIKE " & Chr(34) & cr(8) & Chr(34) & " And " & _
"[" & tripDBName & "].CoPayment = " & amt & " And " & _
"[" & tripDBName & "].Case = " & cr(12)
'Debug.Print strWhere
strSQLQuery = strUpdate & strWhere
Set qrydef = db.CreateQueryDef("", strSQLQuery)
qrydef.Execute
End Function
The above works but the results are inconsistent. See URL below to image file. The records marked in green is where the code works. Those in red should have worked, but didn't.
- Before this I tried DAO Find/Update same results.
- Tried closing Access completely and trying again, no luck.
- Does not work on the same records.