MS Access: Loop though recordset

Option Compare Database

Sub SplitPnum()


Dim rst As Recordset
Set rst = CurrentDb.OpenRecordset("Wellington", dbOpenDynaset)

Do While Not rst.EOF

    If rst![pnum] <> "" Then
        rst.Edit
        rst![PNUM1] = SplitMe(rst![pnum], "/", 1)
        rst![PNUM2] = SplitMe(rst![pnum], "/", 2)
        If Len(rst![PNUM2]) = 2 Then
            rst![PNUM2] = Left(rst![DATESORT], 2) & rst![PNUM2]
        End If
        rst.Update
    End If

    rst.MoveNext
Loop

rst.Close

End Sub


Function SplitMe(target, deliminator, count) As String

    Dim temp
    SplitMe = ""

    If target <> "" Then
        temp = Split(target, deliminator)
        If count - 1 <= UBound(temp) Then
            SplitMe = temp(count - 1)
        End If
    End If

End Function