How do you expect anyone to troubleshoot code covered up by a warning dialog? Reveal the code to get more answers. I would imagine there is a problem with objlayer, which doesn't seem to be passed or set in the function. Declaring a type does not set its value. Note: There is a special VB newsgroup.