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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to print .csv & .xls & find record counts

Status
Not open for further replies.

vjmanda1

Programmer
Mar 24, 2002
15
US
Hi!

I am automating the impromptu report generation using VB. I could save the report to .xls file but all the columns are coming from the SQL query, instead of the report.

How can I generate the .csv file, with only the listed columns in the report? And also.. is there a way to find the recordcount? Because I donot wat to generate a blank .csv file, if there are no records in that report.

Please help!
 
Do the following check once the report has returned rows, but before you export to CSV:

On Error Resume Next 'To turn off error trapping
x = "x" 'Sets a variable to check
x = ImpRep.GetDataValue(1,1) 'Checks the contents of the first row and column of the query data
if x <> &quot;x&quot; then 'Only proceed if data found
'add export code here

end if

Remember to turn error trapping back on after the check.

Hope this helps,

Dave Griffin



The Decision Support Group
Reporting Consulting with Cognos BI Tools
&quot;Magic with Data&quot;
[pc2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top