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

Use diff table name in VB6 for RDC .rpt

Status
Not open for further replies.

cmgrn

Programmer
Nov 28, 2001
43
US
I have a VB6 program using an Access97 database through ADO and DAO.

I added CR9 RDC to view/print several predesigned .RPTs.

My problem is I want to feed the .RPTs different table names than the ones that they were originally created to use.

The different tables are all identical formats.

I cannot find a way to pass the .RPTs a different table name to run from even though the fields are all the same.

There must be a way to tell the CR application report object to use a different table on the fly when everything else is the same.

Example:
Proof.rpt created using table name 'TimesheetsKraft'.

I want to run the following basic code for tables:
'TimesheetsIBM', 'TimesheetsWendys' and
'TimesheetsGoogle' as well.

Global crxApplication As CRAXDRT.Application
Global crxReport As CRAXDRT.Report
Set crxApplication =
CreateObject "CrystalRuntime.Application")
Set crxReport = crxApplication.OpenReport
(conReportPath & "\Proof.rpt")
With crxReport
For xx = 1 To .Database.Tables.Count
.Database.Tables(xx).SetSessionInfo "", Chr(10)
& GetPassword
Next xx
.ReplacementTableName(1) 'TimesheetsWendys'
.ParameterFields(1).AddCurrentValue dtmStartDate
.ParameterFields(2).AddCurrentValue dtmEndDate
End With
Load frmCRViewer

Note the new property called .ReplacementTableName.

Does this simple and straight forward ability exist?

I hope I have been able to explain my situation well enough.

Thanks in advance for your time.

Oh, I have searched Tek-Tips and Business Objects but never found a clear answer. Most concerned changing the path of a database and lots involved changing the Location/Alias of a .RPT internally.

Thanks.



 
Have you tried using the Location property? I was just able to do it (CR 10/VB 6/using ODBC and DAO) like this:

Report.Database.Tables(1).Location = "Table2"

where the report was originally designed against "Table1", and both tables share the exact same structure.

-dave
 
Hi, Dave. When I tried ".location" it wanted the path to the database not a table name in CR9 Dev. ".name" seemed to work but didnt cover all of the internal references.

I created an empty table from the structure of the original table and specified...
report.database.table(1).name='tblEmptyTable'"

Debug showed that afterwards it used the empty table name in my "report.recordselectionformula = strFormula" line but the report contained data from the original table.

tblEmptyTable is 0 records
tblOriginalTable is 2000 records
strFormula="{tblEmptyTable.Group}='01'".
The result was a report containing all the records from tblOriginalTable for group '01'.

Hopefully somewhere there must be a property that will COMPLETELY replace an internal table name with an alternate (same structure) table name.

Thanks for your help.

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top