DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: set activex control to use at runtime

  1. #1
    Join Date
    Aug 2004

    set activex control to use at runtime

    [Originally posted by laura]

    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)
    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
    Join Date
    Aug 2004

    Re:set activex control to use at runtime

    [Originally posted by Greg DeBacker]

    What if you made an array of the CRYSTALREPORTn objects. That way they would be:

    CRYSTALREPORT(n).ReportFileName = .......
    CRYSTALREPORT(n).Connect = .....

    Or you could do a select case statement like

    Select Case FileIdArray(ArrayPosition)
    Case 0
    CRYSTALREPORT0.ReportFileName = .......
    CRYSTALREPORT0.Connect = .....

    Case 1
    CRYSTALREPORT1.ReportFileName = .......
    CRYSTALREPORT1.Connect = .....
    Case 2
    CRYSTALREPORT2.ReportFileName = .......
    CRYSTALREPORT2.Connect = .....
    End Select


  3. #3
    Join Date
    Aug 2004

    Re:Re:set activex control to use at runtime

    [Originally posted by laura]

    Since 'CRYSTALREPORT1' is the name of a control on the form, I am not clear how you can reference CRYSTALREPORT(n) when refering setting the control's property. How would you define it prior to using it as you showed in your example? Although the Case structure is a good way to implement the multi-report requirement, ideally I would love to have only one block of code as in your CRYSTALREPORT(n) example.

  4. #4
    Join Date
    Aug 2004

    Re:Re:set activex control to use at runtime

    [Originally posted by laura]

    It finally dawned on me regarding your suggestion to create a control array for the crystalreport control. Once I did this I was able to do what I wanted. Thank you VERY MUCH for your help and patience!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center