In InfoPath 2007, you don't need code. In the Designer, click on Tools->Submit Options. Add your submit data connection. Click Advanced and uncheck the "Show success and failure messages". That ought to do it, but I haven't had time to try it. Let us know if that solves your problem.
Patrick Halstead
Project Manager at Qdabra