PDA

View Full Version : Is there a Verify method for VBA?



Mark Huston
November 3rd, 2003, 06:50 PM
Is there a way to apply a "Verify" method programmatically when the report and model have been opened? It would be great to be able to test the model, using Monarch's "Verify" functionality, each time a new report is opened.

Data Kruncher
November 3rd, 2003, 08:03 PM
Mark,

Both the setreportfile and setmodelfile methods return boolean values when called. (I use v502 Std - YMMV)

For instance, you could code the following:

boolSuccess = True
boolReportOK = objMonarch.setreportfile(strReport, False)
if boolReportOK then
boolModelOK = objMonarch.setmodelfile(strModel, False)
if not boolModelOK then
msgbox "Invalid Model File."
boolSuccess = False
end if
else
msgbox "Invalid Report File."
boolSuccess = False
end if

if boolSuccess then
'continue with normal processing
end ifI've used this approach many times.

Hope this helps,
Sandy

Mark Huston
November 4th, 2003, 11:29 AM
Dang.

I get a run-time error 450: "Wrong number of arguments or invalid property assignment".

This line works OK, it returns true because the model was found.


boolOpenMod = MonarchObj.SetModelFile(strModName)This line returns the "Wrong number of arguments or invalid property assignment" error:

boolOKMod = MonarchObj.SetModelFile(strModName, False)Any ideas?

Steve Caiels
November 4th, 2003, 12:14 PM
Hi,

As far as I'm aware, the boolean value is only to "verify" that the file exists. I don't think it verifies that the model is suitable for the report in question (like clicking the verify button in monarch). I may be wrong, I'm not an expert on vb.

Cheers
Steve

Data Kruncher
November 4th, 2003, 01:23 PM
Mark,
Steve is correct. My example only is only reporting that the files exist and could be opened by Monarch. It does not test to see that you've opened the proper model file for your report, or that the model is extracting data as you expect it to.

When I have more time, I can pursue this and will post my result here, but, sorry, I can't do that now.

Any quick ideas, group?

Sandy

Nick Osdale-Popa
November 4th, 2003, 02:45 PM
Your best bet will probably be the FindText() method. If you know that a report is supposed to have certain static information such as a report title, then you can use the FindText() to search for that information and generate an error if it does not find it.

Just my 2c worth.

Mark Huston
November 4th, 2003, 03:59 PM
Truth be told, I doubted that a "verify" method for VBA existed, but I've been surprised before by some very ingenious techniques that have been posted on this list so I thought I'd throw it out to you folks anyway. I'm using V6 Pro.

I was curious because I frequently use Monarch's "Verify" function in the Report view, after applying the model, to make sure the data isn't exceeding the field size. This is essential when first building a model. I also find it handy to check again from time to time, in my environment you never know when a report is going to change without warning. It would be nice to have this function available to VBA ... maybe in a later version? (Hint hint, Mike U.)

Though I still am a bit perplexed as to why Data Kruncher is able to use

boolModelOK = objMonarch.setmodelfile(strModel, False)and not get the same "wrong number of arguments" error I get when I use
boolOKMod = MonarchObj.SetModelFile(strModName, False) Thanks again,
Mark!