Function Code_Fragment_5_8()

Dim dbs As Database, rst As Recordset
Dim Record_Number As Long

Set dbs = CurrentDb


'Here is the query for the assertion. Basically, we are looking for
'the query to be empty
Set rst = dbs.OpenRecordset("SELECT I1.SSN " _
                          & "FROM INCUMBENTS AS I1 " _
                          & "WHERE 1 < (SELECT COUNT (SSN) " _
                          & "           FROM INCUMBENTS AS I2 " _
                          & "           WHERE I1.SSN = I2.SSN AND I1.PCN = I2.PCN " _
                          & "             AND I1.END_DATE = #12/31/9999# " _
                          & "             AND I2.END_DATE = #12/31/9999#); ")
                          
                            
' If the result of the query is empty then the transaction is valid
' In Access, you can check if the result of a query is empty by checking
' the EOF and BOF properties of the output recordset

If rst.EOF And rst.BOF Then
    MsgBox ("Insertion completed")
Else
    MsgBox ("You entered an invalid input")
End If

End Function
