Most of what I do can be done with queries, but I have a spot that I need a bit of code for. I've written the code as a public function so I can call it from a macro where I run the rest of the queries. The code runs fine on its own, and so does the macro until it hits where I call the code from, then it crashes with a "2950" error. The database is in a trusted folder, so that isn't the problem. I'm wondering if I am missing some statements at the end of the code that would return it to the macro. The code is rather lengthy and does involve several nested if statements in a loop, so I didn't want to post the whole code. Like I said, the code is working, it's just crashing the macro. What am I missing?