Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.NewRecord Then
If RecordsetClone.RecordCount = 0 Then
Me. ResidentID = Format(Date, "YYYY") & "-0001"
End If
If RecordsetClone.RecordCount <> 0 Then
If Left(DMax("ResidentID ", "YourActualTableName"), 4) = Format(Date, "YYYY") Then
Me. ResidentID = Format(Date, "YYYY") & "-" & Format(DMax("val(Right([ResidentID],4))", "YourActualTableName", "Left([ResidentID],4) = '" & Format(Date, "YYYY") & "'") + 1, "0000")
Else
Me. ResidentID = Format(Date, "YYYY") & "-0001"
End If
End If
End If
End Sub