Strange random error

thank you everyone for your reply
as i then realized that i need to move the value of quot_id from one form to another, i moved the code to Module and it works flawlessly, albeit not as a function

size=8
chars=string.ascii_uppercase + string.digits
quot_id = ''.join(random.choice(chars) for i in range(size))

thanks

sid