Need help with a script invoked on the button click to validate the customer's open invoices

SOLVED

Hi friends, 

We have a business requirement to have a vb script that would pop up a message box on the sales order entry as soon as we tab out of customer no field or set as a user-invoked button. 

If the customer has any open invoices that are past due?  The logic should do a table-level query to AR_OpenInvoice where screen.customerno = table.customerno and table.balance > 0 and table.invoiceduedate < currentdate.

In case anyone has come across a similar requirement or solution, could you please share your findings. Also if there is alterate solution approach, please recommend and advise.

Thanks

AJ