IF ELSE Statements issue and ISNULL statements
I have a piece of code which looks for a delimeter "/" in a string (e.g. Smith/John) and if it find the "/" then it splits these two strings at the "/"
If the delimiter is not found then the it goes to the next record. however i dont want it to do this, only if the cell is NULL.
If the string has just surname, then i wnat it to update the cell and then go to next record.
The field is called Fullname, and the code below is the original (working) code
I am trying to change this so it if the delimter is not found but the cell is not empty then the surname = fullname and then goes to next row, but iof the "/" is not found AND the cell is empty i want it to go to next record.
Or maybe somehting like this?
I think i have my IF ELSE statements in a mess. I am getting a Loop without Do error.
I have a piece of code which looks for a delimeter "/" in a string (e.g. Smith/John) and if it find the "/" then it splits these two strings at the "/"
If the delimiter is not found then the it goes to the next record. however i dont want it to do this, only if the cell is NULL.
If the string has just surname, then i wnat it to update the cell and then go to next record.
The field is called Fullname, and the code below is the original (working) code
Code:
Do Until rs.EOF
numCols = 0
Dim pos As Long
pos = InStr(rs("Fullname"), "/")
If pos = 0 Then GoTo NextRow
rs.Edit
rs("Surname") = Mid(rs("FullName"), 1, pos - 1)
remnant = Mid(rs("Fullname"), pos + 1)
words = Split(remnant)
Code:
Do Until rs.EOF
Dim pos As Long
pos = InStr(rs("Fullname"), "/")
If rs("Fullname") = NULL Then GoTo NextRow
If pos = 0 AND rs("Fullname") = IS NOT NULL then
rs.edit
rs("Surname") = rs("Fullname")
GoTo NextRow
Else
rs("Surname") = Mid(rs("Fullname"), 1, pos - 1)
remnant = Mid(rs("Fullname"), pos + 1)
.
.
Code:
Do Until rs.EOF
Dim pos As Long
If rs("FullName") = "" Then GoTo NextRow
pos = InStr(rs("FullName"), "/")
rs.Edit
If pos = 0 Then
rs("Surname") = rs("FullName") GoTo NextRow
rs("Surname") = Mid(rs("FullName"), 1, pos - 1)
remnant = Mid(rs("FullName"), pos + 1)
Last edited: