Hi, I currently have working code to change my tables at runtime both for the regular report and sub reports. The problem is it is so slow working and I was wondering if there was a speedier way??
'===============================================================
' CHANGING THE MAIN REPORT DATABASE INFO
'===============================================================
'Get the collection of tables in the main report
Set Tables = Session("oClientDoc" & i).DataDefController.Database.Tables
For Each table in Tables
'clone the table object
Set newTable = Table.Clone
'set the table's connectionInfo to the current connection info
newTable.ConnectionInfo = oDBInfo
'set the table object qualified name to include the new database name
'i.e. original = 'db1.dbo.myTable', new = 'db2.dbo.myTable'
newTable.QualifiedName = Database & ".dbo." & Table.Name
'put this newly modified table object back into the report client doc
Session("oClientDoc" & i).DatabaseController.SetTableLocation table, newTable
Next
'===============================================================
' CHANGING THE DATABASE FOR ALL SUBREPORTS
'===============================================================
'get a collection of subreport names
Set subReportNames = Session("oClientDoc" & i).SubReportController.QuerySubreportNames
For each subName in subReportnames
'we can't reference a subreport table object directly, so we get the collection of tables first
Set subTables = Session("oClientDoc" & i).SubReportController.GetSubreportDatabase(subName).Tables
For each subTable in subTables
'clone the subreport table object
Set newSubTable = subTable.Clone
'set the subreport table's connectionInfo to the current connection info
newSubTable.ConnectionInfo = oDBInfo
'set the table object qualified name to include the new database name
'i.e. original = 'db1.dbo.myTable', new = 'db2.dbo.myTable'
newSubTable.QualifiedName = Database & ".dbo." & subTable.Name
'put this newly modified table object back into the report client doc
Session("oClientDoc" & i).SubReportController.SetTableLocation subName, subTable, newSubTable
Next
Next
'===============================================================
' CHANGING THE MAIN REPORT DATABASE INFO
'===============================================================
'Get the collection of tables in the main report
Set Tables = Session("oClientDoc" & i).DataDefController.Database.Tables
For Each table in Tables
'clone the table object
Set newTable = Table.Clone
'set the table's connectionInfo to the current connection info
newTable.ConnectionInfo = oDBInfo
'set the table object qualified name to include the new database name
'i.e. original = 'db1.dbo.myTable', new = 'db2.dbo.myTable'
newTable.QualifiedName = Database & ".dbo." & Table.Name
'put this newly modified table object back into the report client doc
Session("oClientDoc" & i).DatabaseController.SetTableLocation table, newTable
Next
'===============================================================
' CHANGING THE DATABASE FOR ALL SUBREPORTS
'===============================================================
'get a collection of subreport names
Set subReportNames = Session("oClientDoc" & i).SubReportController.QuerySubreportNames
For each subName in subReportnames
'we can't reference a subreport table object directly, so we get the collection of tables first
Set subTables = Session("oClientDoc" & i).SubReportController.GetSubreportDatabase(subName).Tables
For each subTable in subTables
'clone the subreport table object
Set newSubTable = subTable.Clone
'set the subreport table's connectionInfo to the current connection info
newSubTable.ConnectionInfo = oDBInfo
'set the table object qualified name to include the new database name
'i.e. original = 'db1.dbo.myTable', new = 'db2.dbo.myTable'
newSubTable.QualifiedName = Database & ".dbo." & subTable.Name
'put this newly modified table object back into the report client doc
Session("oClientDoc" & i).SubReportController.SetTableLocation subName, subTable, newSubTable
Next
Next