Am trying to error trap whenever a name is changed on a form by the addition of a space at the end or any place in the name. If I do a search on the name with the errant space, it is found using a filter. Therefore the boolean bFound is true.
However, during the next step, using a loop, the record can not be found. Have tried using the trim fct, no luck. First I do a search:
sSql = "SELECT * FROM Members WHERE Lastname = '" & sLast & "'AND" & _
" Firstname = '" & sFirst & "'"
rs.Open sSql, cData
rs.Filter = "Lastname = '" & sLast & "' AND Firstname = '" & sFirst & "'" 'LTrim(slast) does not work
If rs.EOF Then
bNameFound = False
Else
bNameFound = True
lngID = rs!ID
End If
Since bFound is true, next is the search on the name. Once the name is found, movenext to list the next record:
sSql = "Select * FROM Members ORDER BY Lastname, Firstname"
rs.CursorLocation = adUseClient
rs.Open sSql, cData
Do Until rs!LastName = sLast And rs!FirstName = sFirst
rs.MoveNext
Loop
rs.MoveNext
If rs.EOF Then
rs.MoveFirst
If rs.BOF Then
Exit Sub
End If
End If
Example, if there are spaces after the lastname, the loop will not find the record which causes an EOF/BOF error. It seems that the error trapping should come on the first procedure, but I am at a loss as how to.
Any help is appreciated.
Kim
However, during the next step, using a loop, the record can not be found. Have tried using the trim fct, no luck. First I do a search:
sSql = "SELECT * FROM Members WHERE Lastname = '" & sLast & "'AND" & _
" Firstname = '" & sFirst & "'"
rs.Open sSql, cData
rs.Filter = "Lastname = '" & sLast & "' AND Firstname = '" & sFirst & "'" 'LTrim(slast) does not work
If rs.EOF Then
bNameFound = False
Else
bNameFound = True
lngID = rs!ID
End If
Since bFound is true, next is the search on the name. Once the name is found, movenext to list the next record:
sSql = "Select * FROM Members ORDER BY Lastname, Firstname"
rs.CursorLocation = adUseClient
rs.Open sSql, cData
Do Until rs!LastName = sLast And rs!FirstName = sFirst
rs.MoveNext
Loop
rs.MoveNext
If rs.EOF Then
rs.MoveFirst
If rs.BOF Then
Exit Sub
End If
End If
Example, if there are spaces after the lastname, the loop will not find the record which causes an EOF/BOF error. It seems that the error trapping should come on the first procedure, but I am at a loss as how to.
Any help is appreciated.
Kim