It is a scoping issue. Looks like you aren't declaring your variables, so in the getmycode function, myerror is a local variable. Should always declare your vars. The way you have it, passing myerror by reference will solve the problem (see below), but I still reccomend declaring all variables. Option Explicit at the top of your script will help iron these types of issues out.
function getmycode([b]byVal pin, byRef myerror[/b])
'I get the code from teh db
if rs.bof and rs.eof then
myerror="error no such pin in db"