here is last code
Public Function IsTransferValid(DocNumber As Long, Transfer As String, DateOfReceiving As Date) As Boolean
On Error GoTo HandleError
Dim parts() As String
Dim startDoc As Long, endDoc As Long
Dim thisYear As Long
Dim rs As DAO.Recordset
Dim dateStart As...