Public ch As Recordset
Dim fld As String, Tline As String, Logger As String, Fbuffer As String, tot As Double
Dim rr As Recordset, RT As Recordset
Dim db As Database
Set db = CurrentDb
'-----------------------------------------------------------------------------------
' Clear the target table
'-----------------------------------------------------------------------------------
DoCmd.SetWarnings False
DoCmd.RunSQL "DELETE * FROM TargetTbl"
DoCmd.SetWarnings True
'-------------------------------------------------------------------------------------------
' Define and set recordsets
'--------------------------------------------------------------------------------------------
Set rr = db.OpenRecordset("OriginalTbl")
Set RT = db.OpenRecordset("TargetTbl")
Set ch = db.OpenRecordset("SearchingTbl")
'----------------------------------------------------------------------------------------------
' get the highest total value to use in calculations
'----------------------------------------------------------------------------------------------
ch.MoveFirst
Do While Not ch.EOF
If ch.Fields("Action").Value = "9" Then
tot = CDbl(ch.Fields("SearchTerm").Value)
Debug.Print "tot="; tot
Exit Do
Else
ch.MoveNext
End If
Loop
'----------------------------------------------------------------------------------------------
' Set record counters
'----------------------------------------------------------------------------------------------
IR = 0
IT = 0
IK = 0
rr.MoveFirst
RT.MoveFirst