in reply to Re^3: Looking for neater solution with dynamic queryin thread Looking for neater solution with dynamic query