Results 1 to 5 of 5

Thread: dynamically set activex control to use at runtime

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2000
    Location
    Princeton NJ
    Posts
    16

    Question dynamically set activex control to use at runtime

    I have a form which has a number of Crystal Report ActiveX Controls defined to it. I would like to be able to activate the use of a given control at runtime based on the data being read. I do this because multiple Crystal Reports will be open at any given point.

    Here is an example. My form has 4 Crystal Report ActiveX controls defined to it (CRYSTALREPORT0 thru CRYSTALREPORT3). My pseudo-code is as follows:
    **********
    FileIdArray = Array("BC", "CA", "CI", "CM")
    For ArrayPosition = 0 To 3
    (Get data associated with the value in FileIdArray)
    (If data is found run activate the CRYSTALREPORTn object on
    the form. 'n' is to be based on the ArrayPosition
    value. For example if I have found CA data then the
    activex control to be activated is CRYSTALREPORT1,
    if I have found CM data then it would be
    CRYSTALREPORT3 so the control name to use is derived
    by concatenating 'CRYSTALREPORT' and the value in
    ArrayPosition)
    Next
    **************
    So how do I dynamically format the following types of statements, replacing the 'n' with the appropriate ArrayPosition:
    CRYSTALREPORTn.ReportFileName = .......
    CRYSTALREPORTn.Connect = .....

    I tried just setting a variable to the concatenation result and using the variable as such: variable.ReportFileName = ..... but it didn't work.

    Any suggestions much appreciated!

  2. #2
    Addicted Member
    Join Date
    Oct 1999
    Location
    The Lone Star State
    Posts
    183
    Why don't you just use one Crystal Report control and set the properties in code based on the array index?

    Select Case X
    Case "CA"
    Rpt1.Reportfilename= ".....
    Rpt1.Connect = "....
    Case "BC"
    Rpt1.Reportfilename = "....


    blah, blah
    !

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Dec 2000
    Location
    Princeton NJ
    Posts
    16
    The reason I am using more than one Crystal control is that multiple reports (based on those identifiers CA, CM ...) are displayed to the user at once. If you use only one Crystal control for all of them the user would not be able to page thru any of the reports except for the report that used the control last in creating that report........

  4. #4
    Addicted Member
    Join Date
    Oct 1999
    Location
    The Lone Star State
    Posts
    183
    How about making your Crystal Report objects a control array, such as CrystalReport(1), etc. and use the index from your string array to call the report?
    !

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Dec 2000
    Location
    Princeton NJ
    Posts
    16
    I took your suggestion and made the crystal report controls a control array and then aligned them with my fileid/filename array. It then worked like a champ. Thanks so much for your time and assitance. MUCH APPRECIATED!

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