Results 1 to 2 of 2

Thread: Dynamically Assigning Tables

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2000
    Location
    Tennessee
    Posts
    279

    Question Dynamically Assigning Tables

    I have two tables. One that reflects data for the past 3 months and one that is an archive table to which data over 3 months old is sent. They are identical in their design with the exception that the table name is different. Is there a way to design a report such that a user could choose from the current or archived tables before the report is populated? My current report is written in Crystal Reports 9 and only reflects current data. Thanks in advance.
    A cynic knows the price of everything but the value of nothing.

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    If you are using the CRAXDRT Report object then you can change the data source at runtime. You can change the Server, Database and Tables if you want.

    The following is an xample that changes the location to a different table. Note that I used the SQL Server native driver - may be different for other databases. Also, I am using version 8.5.

    VB Code:
    1. Dim objCrystal As CRAXDRT.Application
    2.     Dim objReport As CRAXDRT.Report
    3.    
    4.     Set objCrystal = New CRAXDRT.Application
    5.     Set objReport = objCrystal.OpenReport(ReportFileName)
    6.    
    7.     objReport.Database.Tables(1).SetLogOnInfo 'set login parameters    
    8.     objReport.Database.Tables(1).Location = "Set to Desired Table"
    9.  
    10.     'Show report
    11.     CRViewer1.ReportSource = objReport
    12.     CRViewer1.ViewReport
    13.  
    14.     'Clean up
    15.     Set objReport = Nothing
    16.     Set objCrystal = Nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width