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

CR9, TTX files and Visual Basic Integration...

Status
Not open for further replies.

mattKnight

Programmer
May 10, 2002
6,231
GB
Hi All,

This is a post made in the VB forum, which has sunk without trace there. Is anyone here able to offer some help?
I have a SQL database and CR9 Advanced I wish to create a recordset on the fly in code and pass to CR for display.

I have done the following,

Stage 1 - Created ttx file (had to do it manually as CR9.1 has made the api call you suggest obsolete..) I have even added sample data into the file.

Stage 2 & 3 - Created report usng TTX file... This works OK with smaple data

Stage 4 Created record set from SQL server (used command object) (yes it does return records) and passed ado recordset to CR using setDatasource See the code snippet below...
Code:
Set adoRS = adoCmd.Execute

Screen.MousePointer = vbHourglass
rep.Database.Tables.Item(1).SetDataSource adoRS, 3

CRViewer91.ReportSource = rep
CRViewer91.ViewReport

Screen.MousePointer = vbDefault

Ths code execute without an error, andshows a report in the viewer however, it shows the sample data in the TTX file only. If I edit the TTX file to remove the sample, verfiy report etc, I get a blank report viewed.

Where am I going wrong, does the name of the recordset (adoRS) need to match the ttx file? Do I need to map fields?
Any suggestions gratefully accepted!

Does anyone have any suggestions as to why I only get the test data in the TTX file shown when the viewreport method is called?
Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
Hi matt

I've never created reports using TTX files, but a couple of things come to mind.

is your report saved with data ? if so try saving the report without data so that it has to retrieve the data each time.

Try also using the DiscardSavedData command of your report object before viewing the report.

HTH Gary Parker
Systems Support Analyst
 
Add the remarked lines to your code.

Set adoRS = adoCmd.Execute

Screen.MousePointer = vbHourglass
rep.Database.Tables.Item(1).SetDataSource adoRS, 3

'Add this line. It forces records to be read.
rep.ReadRecords

CRViewer91.ReportSource = rep
CRViewer91.ViewReport

Screen.MousePointer = vbDefault
 
GJParker

I had already tried saving the report without data from report designer and tried discarding data from code too.

afbird

Adding .readrecords does nothing...

thank you both! any other suggestions

Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
Hello,

I'm little late but I'm currently working on a similar thing. I just thought this might help...

Instead of doing a:
rep.Database.Tables.Item(1).SetDataSource adoRS, 3

Try this:
rep.Database.SetDataSource adoRS

You might also want to try doing these after the setdatasource:
rep.Database.Tables(1).SetTableLocation ttx_filename, "", ""
rep.Database.Tables(1).SetLogOnInfo ttx_filename, ttx_filepath & ttx_filename
rep.Database.Tables(1).CheckDifferences 0
rep.Database.Verify
rep.ReadRecords

hope this helps...

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top