Hi Srinath,
I'm really sorry, but we don't provide sample code anymore to people for specific problems. We have too many requests and if we responded to all of them we would have no time to actually do paid work. Instead, we give general best practice and guidance to people for free. If there is a coding problem that is general, we may help debug it and offer suggestons, but we don't write code for people. Also, code is a bad practice for InfoPath.
Best practice here is to use the non-code solution. It's cheap because you don't have to maintain it and it's relatively easy to do. Could take several hours of our time. Of course, it could take you longer and you'd have to be patient and persistent. Basically, that's life, you have to solve problems yourself sometimes. If you want to hire someone on our team to help you, we'd be happy to give you a good rate, but we have to do work that pays the bills (since this forum is free and we don't make money off of advertising). Thanks for your understanding! :)
Respectfully,