Vij
April 19th, 2001, 11:36 PM
Hi All,
I am trying to set up a mechanism where a user can create the report he wants by selecting a subsets of fields(by checking the check boxes) in the application from a set of predefined fields.
Plan is to have one procedure, which fetches these fields from the database on the fly based on the selection. Using this recordset create a ttx and rpt on the fly(as in the code) and then display the report.
I am not able to get this working with the following code, It will work if I manually open the rpt file that is created and map the fields from the database (ttx in this case) as column heades in the rpt file. Can somebody tell me how to automate this mapping process.
Dim oRptTables as Object
Dim oRptTable as Object
Dim rs as new ADODB.Recordset
Dim con as new ADODB.Connection
con.Open "mydsn", "sa", "sapassword"
rs.CursorLocation = adUseClient
set rs.ActiveConnection = con
rs.Open ("select * from myreport")
Call CreateReportOnRuntimeDS(rs, "c:\2.rpt", "c:\1.ttx", 1, 0)
set gApplnCrystal = CreateObject("Crystal.CRPE.Application")
Call OpenReport("c:\2.rpt", mRptCrystal)
set oRptTables = GetReportDbTables(mRptCrystal)
'can use foreach in the following statement
set oRptTable = oRptTables.Item(1)
If rs.RecordCount > 0 then
oRptTable.SetPrivateData 3, rs
mRptCrystal.Preview
End If
2. How to uncheck the save data with report option programatically ?
Thanks,
Vijay
I am trying to set up a mechanism where a user can create the report he wants by selecting a subsets of fields(by checking the check boxes) in the application from a set of predefined fields.
Plan is to have one procedure, which fetches these fields from the database on the fly based on the selection. Using this recordset create a ttx and rpt on the fly(as in the code) and then display the report.
I am not able to get this working with the following code, It will work if I manually open the rpt file that is created and map the fields from the database (ttx in this case) as column heades in the rpt file. Can somebody tell me how to automate this mapping process.
Dim oRptTables as Object
Dim oRptTable as Object
Dim rs as new ADODB.Recordset
Dim con as new ADODB.Connection
con.Open "mydsn", "sa", "sapassword"
rs.CursorLocation = adUseClient
set rs.ActiveConnection = con
rs.Open ("select * from myreport")
Call CreateReportOnRuntimeDS(rs, "c:\2.rpt", "c:\1.ttx", 1, 0)
set gApplnCrystal = CreateObject("Crystal.CRPE.Application")
Call OpenReport("c:\2.rpt", mRptCrystal)
set oRptTables = GetReportDbTables(mRptCrystal)
'can use foreach in the following statement
set oRptTable = oRptTables.Item(1)
If rs.RecordCount > 0 then
oRptTable.SetPrivateData 3, rs
mRptCrystal.Preview
End If
2. How to uncheck the save data with report option programatically ?
Thanks,
Vijay