G
Guest
I am trying to create some code to capture the first 2 letters in a string. I wish to ignore all else. I think that I am close, but I am a novice at this. Vndr1 is the first character, Vndr2 is the second character, and Vendor Number is the field that I am looking at to find these characters.
For k = 1 To Len(Me![Vendor Number])
If IsNull(Vndr1) Then
If Mid([Vendor Number], k, 1) Like "[a-z]" Or "[A-Z]" Then
Vndr1 = Mid([Vendor Number], k, 1)
l = k + 1
k = Len(Me![Vendor Number])
End If
End If
Next k
For k = l To Len([Vendor Number])
If IsNull(Vndr2) Then
If Mid([Vendor Number], k, 1) Like "[a-z]" Or "[A-Z]" Then
Vndr2 = Mid([Vendor Number], k, 1)
k = Len(Me![Vendor Number])
End If
End If
Next k
For k = 1 To Len(Me![Vendor Number])
If IsNull(Vndr1) Then
If Mid([Vendor Number], k, 1) Like "[a-z]" Or "[A-Z]" Then
Vndr1 = Mid([Vendor Number], k, 1)
l = k + 1
k = Len(Me![Vendor Number])
End If
End If
Next k
For k = l To Len([Vendor Number])
If IsNull(Vndr2) Then
If Mid([Vendor Number], k, 1) Like "[a-z]" Or "[A-Z]" Then
Vndr2 = Mid([Vendor Number], k, 1)
k = Len(Me![Vendor Number])
End If
End If
Next k