Option Compare Database
Public strFileName As String
Public strNewFileName As String
Public strDataSource As String
Public strConnection As String
Public strSQLStatement As String
Public StrReportName As String
Public StrQryName As String
Public iCount As Integer
Public CurrentGroupNum As String
Public CurrentSection As String
Public bGroupNumSame As Boolean
'Public bSectionSame As Boolean
Public bSame As Boolean
Dim DtEffDate(90) As Date
Dim DtEndDate(90) As Date
Dim Premium(90) As Currency
Dim TransRowID(90) As Long
Dim DeterminedOED As Date
Dim DeterminedRowID As Long
Dim DeterminedCovEffDate As Date
Dim strGroupNum(90) As String
'Dim strSection(90) As String
'Public iCount As Integer
Dim i As Integer
Public DB As Database
'public rst As Recordset
Public MyForm As Form
Option Explicit
Public Function A_CheckAllTrans()
Dim SFilename As String
Dim BFound As Boolean
Dim StrMemberID As String
Dim SFullSSN As String
Dim StrSQL As String
Dim StrSQL1 As String
Dim SProdName As String
Dim SChannel As String
'Dim cn As ADODB.Connection
Dim rst As Recordset
Dim rst1 As Recordset
Dim rst2 As Recordset
Dim rst3 As Recordset
Dim ISSNLength As Integer
Dim IDiff As Long
Dim RC As Integer
Dim RowID As Integer
Dim StrReason As String
Dim StrReason1 As String
Dim IZeros As Integer
Dim RecCount As Long
Dim CL As Integer
Set DB = CurrentDb()
DAO.DBEngine.SetOption dbMaxLocksPerFile, 1000000
Set rst = DB.OpenRecordset("select * from UniqueRecs where fixed = 0")'selects unique member ID where the record hasn't been updated
If rst.EOF Or rst.BOF Then '1
rst.Close
MsgBox " There were no records found in the UniqueRecs Table. Check to be sure you did it correctly."
Exit Function
Else
RecCount = 1
rst.MoveFirst
Do Until rst.EOF
StrMemberID = rst("member_ID")
'StrMemberID = "804276499"
Set rst1 = DB.OpenRecordset("SELECT * from trans where fixed = 0 and member_ID = '" & StrMemberID & "'ORDER BY trans.Membership_Effective_Date DESC")
If rst1.EOF Or rst1.BOF Then '2
rst1.Close
'MsgBox " There were no records found in the trans Table. Check to be sure you did it correctly."
'Exit Function
Else
RC = DCount("[Member_ID]", "trans", "Member_ID = '" & StrMemberID & "'")
rst1.MoveFirst
RowID = 1
'sets array values here
Do Until rst1.EOF
DtEffDate(RowID) = rst1("membership_effective_date")
DtEndDate(RowID) = rst1("membership_end_date")
If Not IsNull(rst1("group_number")) Then
strGroupNum(RowID) = rst1("group_number")
Else
strGroupNum(RowID) = "11111" 'in case of a null value
End If
'strSection(RowID) = rst1("section_number")
TransRowID(RowID) = rst1("-RowNum-")
'Premium(RowID) = rst1("tot_prem")
'check values here
rst1.MoveNext
RowID = RowID + 1
Loop
'RowID = 1
i = 1
BFound = False
rst1.MoveFirst
RowID = 1
RecCount = 0
If RC = 1 Then 'if there is only 1 record do the rst1 assignment here
StrReason = "1 Record"
DeterminedOED = DtEffDate(i)
rst1("DeterminedOED") = DeterminedOED
rst1("reason") = StrReason
rst1("fixed") = True
rst1.Update
'DeterminedCovEffDate = DtEffDate(i)
'UpdateTrans DeterminedOED, i
Else'if more than 1 then do the rst1 assignment here by comparing records
For i = i To RC
IDiff = DateDiff("d", DtEndDate(i + 1), DtEffDate(i))
'
If IDiff > 0 Then '4
RecCount = RecCount + 1
If DtEndDate(i + 1) = "12:00:00 AM" Then 'checks for no record
DeterminedOED = DtEffDate(i)
StrReason = "No Gap"
'CoverageEffDate i
Else
DeterminedOED = DtEffDate(i)
StrReason = "Gap"
If i = 1 Then
DeterminedCovEffDate = DtEffDate(i)
CurrentGroupNum = strGroupNum(i)
'CurrentSection = strSection(i)
Else
'CoverageEffDate i
End If
End If
'***************************
Set rst2 = DB.OpenRecordset("SELECT * from trans where fixed = 0 and Membership_Effective_Date >= #" & DeterminedOED & "# and member_ID = '" & StrMemberID & "' ORDER BY trans.Membership_Effective_Date DESC")
rst2.MoveFirst
Do Until rst2.EOF
rst2.Edit
rst2("DeterminedOED") = DeterminedOED
'rst2("DeterminedCovEffDate") = DeterminedCovEffDate
rst2("reason") = StrReason
rst2("fixed") = True
rst2.Update
rst2.MoveNext
Loop
rst2.Close
'
rst.Edit
rst("fixed") = True
rst.Update
'update records
Else
RecCount = RecCount + 1
End If '4
rst1.MoveNext
RowID = RowID + 1
Next i
End If '5
End If '2
StrReason = " "
StrReason1 = " "
DeterminedOED = Empty
DeterminedRowID = Empty
DeterminedCovEffDate = Empty
CurrentGroupNum = Empty
'CurrentSection = Empty
Erase strGroupNum
'Erase strSection
Erase DtEffDate
Erase DtEndDate
Erase Premium
Erase TransRowID
RowID = 0
RecCount = 0
rst.MoveNext
Loop
rst1.Close
End If ' 1
rst.Close
Exit Function
End Function