Code:
Private Sub Form_Activate()
Dim rs As Variant
Dim varAOProp As Variant
Dim varAOIni As Variant
Dim varAOCert As Variant
Dim varBORIni As Variant
Dim varBORFinal As Variant
Dim varZero As Variant
Dim Rs1 As Variant
Dim RS2 As Variant
Dim RS3 As Variant
Dim RS4 As Variant
Dim RS5 As Variant
Dim intRecordSet As Variant
'Total Squart Footage from sPIN for Property
intRecordSet = DFirst("sumOFLandSF", "TestTotalspinSFforPYD")
Me.TotalLandSF = intRecordSet
Me.Refresh
'Number of Property Year Detail records
rs = Nz(DCount("*", "TestNumPYDRecords"), 0)
Me.TXTCountPYD = rs
Me.Refresh
'Number of SPIN records
rs = Nz(DCount("*", "TestNumSPINRecords"), 0)
Me.TXTCountSPINS = rs
Me.Refresh
'Number of SPYD records
rs = Nz(DCount("*", "TestNumSPYDRecords"), 0)
Me.TXTCountSPYD = rs
Me.Refresh
'EQUATION 1 RS1.
Me.AOProposedAV = Null
Me.AOinitialAVresult = Null
Me.AOResult = ""
Me.AOcertifiedAV = Null
Me.AOreReviewResult = ""
Me.BORInitialAVResult = Null
Me.BORresult = ""
Me.BORfinalAV = Null
Me.BORreReviewResult = ""
Rs1 = DSum("total", "TotalAOProposedAVResult")
If IsNull((Rs1) = True Or (Rs1) = 0) Then
Exit Sub
End If
Me.AOProposedAV = Rs1
'No tests for equation 1
'EQUATION 2 RS2.
RS2 = DSum("total", "TotalAOInitialAVResult")
If IsNull((RS2) = True Or (RS2) = 0) Then
Me.AOinitialAVresult = Null
Me.AOResult = ""
Me.AOcertifiedAV = Null
Me.AOreReviewResult = ""
Me.BORInitialAVResult = Null
Me.BORresult = ""
Me.BORfinalAV = Null
Me.BORreReviewResult = ""
Me.Refresh
Exit Sub
End If
Me.AOinitialAVresult = RS2'EQUATION 2 Test 1
If RS2 = Rs1 Then
Me.AOResult = "NC"
Me.Refresh
End If
'EQUATION 2, Test 2
If RS2 < Rs1 Then
Me.AOResult = "RED"
Me.Refresh
End If
'EQUATION 2, Test 3
If RS2 > Rs1 Then
Me.AOinitialAVresult = Null
Call MsgBox("AO Initial AV Result will be greater than AO Proposed AV total." _
& vbCrLf & "" _
& vbCrLf & "This indicates a Data Error in the SPYD records." _
& vbCrLf & "" _
& vbCrLf & "All related fields will be cleared." _
& vbCrLf & "" _
& vbCrLf & "Click OK to Exit, Locate, and Correct the data." _
, vbCritical, "Incorrect Data")
Me.AOinitialAVresult = Null
Me.AOResult = ""
Me.AOcertifiedAV = Null
Me.AOreReviewResult = ""
Me.BORInitialAVResult = Null
Me.BORresult = ""
Me.BORfinalAV = Null
Me.BORreReviewResult = ""
Me.Refresh
Exit Sub
End If
'EQUATION 3 RS3
RS3 = DSum("total", "TotalAOCertifiedAVResult")
If IsNull((RS3) = True Or (RS3) = 0) Then
Me.AOcertifiedAV = Null
Me.AOreReviewResult = ""
Me.BORInitialAVResult = Null
Me.BORresult = ""
Me.BORfinalAV = Null
Me.BORreReviewResult = ""
Me.Refresh
End If
Me.AOcertifiedAV = RS3
'EQUATION 3, Test 1.
If RS3 = RS2 Then
Me.AOreReviewResult = "NC"
Me.Refresh
End If
'EQUATION 3, Test 2.
If RS3 < RS2 Then
Me.AOreReviewResult = "RED"
Me.Refresh
End If
'EQUATION 3 Test 3.
If RS3 > RS2 Then
Call MsgBox("AO Certified AV will be greater than AO Initial AV Result total." _
& vbCrLf & "" _
& vbCrLf & "This indicates a Data Error in the SPYD records." _
& vbCrLf & "" _
& vbCrLf & "All related fields will be cleared." _
& vbCrLf & "" _
& vbCrLf & "Click OK to Exit, Locate, and Correct the data." _
, vbCritical, "Incorrect Data")
Me.AOcertifiedAV = Null
Me.AOreReviewResult = ""
Me.Refresh
Exit Sub
End If
'EQUATION 4, RS4
RS4 = DSum("total", "TotalBORInitialAVResult")
Me.BORInitialAVResult = RS4
If IsNull((RS4) = True Or (RS4) = 0) Then
Me.BORresult = ""
Me.BORfinalAV = Null
Me.BORreReviewResult = ""
Me.AOcertifiedAV = Null
Me.AOreReviewResult = ""
Me.Refresh
End If
'EQUATION 4, Test 1.
If RS4 = RS3 Then
Me.BORresult = "NC"
End If
'EQUATION 4, Test 2.
If RS4 < RS3 Then
Me.BORresult = "RED"
End If
'EQUATION 4, Test 3.
If RS4 > RS3 Then
Call MsgBox("BOR Initial AV Result will be greater than AO Certified AV Result total." _
& vbCrLf & "" _
& vbCrLf & "This indicates a Data Error in the SPYD records." _
& vbCrLf & "" _
& vbCrLf & "All related fields will be cleared." _
& vbCrLf & "" _
& vbCrLf & "Click OK to Exit, Locate, and Correct the data." _
, vbCritical, "Incorrect Data")
Me.AOcertifiedAV = Null
Me.AOreReviewResult = ""
Me.Refresh
Me.BORInitialAVResult = Null
Exit Sub
End If
'EQUATION 5, RS5RS5 = DSum("total", "TotalBORFinalAVResult")
Me.BORfinalAV = RS5
If IsNull((RS5) = True Or (RS5) = 0) Then
Me.AOcertifiedAV = Null
Me.AOreReviewResult = ""
Me.Refresh
Me.BORInitialAVResult = Null
Me.BORresult = ""
Me.Refresh
Me.BORfinalAV = Null
Me.BORreReviewResult = ""
Me.Refresh
Exit Sub
End If
'EQUATION 5, Test 1.
If RS5 = RS4 Then
Me.BORreReviewResult = "NC"
End If
'Equation 5, Test 2.
If RS5 < RS4 Then
Me.BORreReviewResult = "RED"
End If
'Equation 5, Test 3.
If RS5 > RS4 Then
Call MsgBox("BOR Final AV will be greater than BOR Initial AV Result." _
& vbCrLf & "" _
& vbCrLf & "This indicates a Data Error in the SPYD records." _
& vbCrLf & "" _
& vbCrLf & "All related fields will be cleared." _
& vbCrLf & "" _
& vbCrLf & "Click OK to Exit, Locate, and Correct the data." _
, vbCritical, "Incorrect Data")
Me.BORInitialAVResult = Null
Me.AOcertifiedAV = Null
Me.AOreReviewResult = ""
Me.Refresh
Me.BORInitialAVResult = Null
Me.BORresult = ""
Me.Refresh
Me.BORfinalAV = Null
Me.BORreReviewResult = ""
Me.Refresh
Exit Sub
End If
End Sub
Thanks again, Phred