Very confused now....
I created a new database and main form, then copied just the troublesome parts to the new database. The search worked fine which seems to indicate the code is okay.
The part of the system that has been causing problems consists of two subforms. A module, triggered by...