That line does most likely not cause the error. Can you post the complete script you use?

The $form.DoEvents part is used in kixforms. To be able to see what goes wrong it would be very helpful to see the entire script.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.