I am not a query builder fan (at all) but I have done this for the Search widget. Keep in mind that this in definitely no novice undertaking but here is the link http://forums.esri.com/Thread.asp?c=158&f=2421&t=294907&mc=104#msgid946887 If you are going to attempt to do this make sure you read all of the thread as there a instructions scattered though out the thread.