A couple of tips to help you get the most out of this site:
1. When posting code, UseCodeTags(←click). It makes the code much easier to read. I've done it for you in your post here.
2. Be specific. Just saying you get an error doesn't tell us anything useful. Copy/paste the exact, complete error message, and indicate clearly which line is causing it.
3. UseAMeaningfulSubjectLine(←click). This goes along with #2. I provided a generic subject when I split your post off from the older thread where you originally placed it, but you can go back and edit it to something that provides a bit more information about your problem. For example, stating what error you're getting would be at least marginally more useful.