Hmmm...
I've recreated this on my server as so
update dbo.SalesmanList
set lengthofRepCode = dbo.tester(RepCode)
where Name = 'Alan Lese'
the dbo.tester function doesn't reference any tables, just takes the varchar data parameter given and returns the length of the string, and then updates the table column oldaocpersno to whatever that is. I set up two records for the Alan Lese name, but with different length data in the RepCode column, and it worked perfect for me.
I'd really need to see your function i think to help you further, sorry.