Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running Macro - Verify records exists

Status
Not open for further replies.

mrpauly

Programmer
May 11, 2001
23
0
0
Hello,

Using macros, I've automated the process to run about 50 reports passing parameters via prompts. My question is I would like to export to PDF the report only if records are found.

Is there a method to verify records exists?

Thanks - Paul
 
Paul,

See thread401-165889. You can use GetDataValue to query the report. It will return an error if no rows are found. You can trap this error by setting a variable to a constant before the GetDataValue call, and then change the variable value with this call. Bypass the error by using On Error Resume Next and check the variable value after the call. If it hasn't changed from the original constant, no rows were returned.

An alternative is to replicate the report filter in a SQL query and use SQLExecute and SQLRetrieve to get a row count. In either case, just don't print or output the report if it is empty.

Hope this helps,

Dave Griffin
The Decision Support Group
Reporting Consulting with Cognos BI Tools
"Magic with Data"
[pc2]
 
You're welcome! I too was so relieved when I figured out this was the solution. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top