Function Code_Fragment_5_17()

Dim dbs As Database
Dim 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 * " _
                          & "FROM INCUMBENTS AS I " _
                          & "WHERE  NOT EXISTS ( " _
                          & "SELECT * " _
                          & "FROM POSITIONS AS P " _
                          & "WHERE I.PCN = P.PCN " _
                          & "AND P.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
