What is "Access Command" event? Exactly where are you running this code? A button Click event?

Posting under Access forum is probably best because you want to code in Access. Continue discussion in other thread.