If a record is found it closes the form and displays the found record in the second form. If a record is not found, it closes the search form and returns a message. But when I search again, the previous text is still in the search box. Is it possible to clear this out?

Re: Access Forms (2003)

Re: Access Forms (2003)

Explanation (mainly for others reading this thread): if opening the form in the line

DoCmd.OpenForm ...

gets canceled, error 2501 occurs, and the code jumps from DoCmd.OpenForm to the error handling section, skipping DoCmd.Close in its original position. So the search form was only hidden, not really closed. Next time it was actually only unhidden instead of opened from scratch, so the search box still contained the old search text. Moving the DoCmd.Close line to the exit handler section ensures that it is *always* executed.