You need to build logic to triger message only on surtain condition. If 'else' condition is met call the code to invoke the 'PrintButton' 'Click' event.
A simple logic would like this...
if(){ //condition which gives message box
//step1;
//step2;
xfa.host.mesageBox();
//step3;
}else {
form1.PrintButton.ececEvent("click");
//replace above expression with actual SOM expression.
}
Good Luck,
SekharN
www.lawson.com