The only problem I have with that methodology has to do with what you're goal of testing is. Part of the feature set of your product is that, if the company does not exist, prompt. You're bypassing that part of your application code that generates the dialogue box and kind of cheating it. It will work and do what you want, but what if the company does not exist and the dialog box never appears? Then your select query will return that the company exists and the script will try to click a button on a form that does not exist.
You can do the select query as you mentioned, but I'd expand one step beyond and test for the existance of the dialog as well. If the select query returns no records, then check with the Wait method to see if the dialog comes up. If the dialog comes up, click the button and move on. If the dialog does NOT come up, then you have a scenario that is actually a bug because a prompt that was supposed to generate did not.
It all comes down as to what you are testing.