Results 1 to 12 of 12

Thread: Passing parameters with vb6 to CR11

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2006
    Posts
    320

    Passing parameters with vb6 to CR11

    I would like to pass some values from VB6 to CR11. Ifound some code posted. I have tried but get the following error. Here is the code I copied from here and the associated error.

    VB Code:
    1. Sub RunReport()
    2. Dim crxApp As New CRAXDDRT.Application
    3. Dim crxReport As CRAXDDRT.Report
    4. Dim crxDatabaseTables As CRAXDDRT.DatabaseTables
    5. Dim crxDatabaseTable  As CRAXDDRT.DatabaseTable
    6. Dim crxDatabase As CRAXDDRT.Database
    7. Dim crxParm As CRAXDDRT.ParameterValues
    8. Dim crxSubReport As CRAXDDRT.Report
    9.  
    10. Dim ReportName As String
    11.  
    12. ReportName = "C:\Consulting\Georgia\Cutbill\Reports\Guide.rpt" 'Report Path
    13.  
    14. Set crxReport = crxApp.OpenReport(ReportName)
    15.  
    16. crxReport.ParameterFields.GetItemByName("Door Series").AddCurrentValue (CBDoorCode(CBLI))
    17. crxReport.ParameterFields.GetItemByName("Slat Type").AddCurrentValue CBSlatType(CBLI)
    18.  
    19. 'crxReport.PrintOut False, 1 'uncomment to printout the report
    20.  
    21. With crView 'Control Name
    22.     .ReportSource = crxReport
    23.     .ViewReport
    24.     While .IsBusy
    25.         DoEvents
    26.     Wend
    27.     .Zoom "75"
    28.     .Visible = True
    29. End With
    30. End Sub
    Attached Images Attached Images  

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Passing parameters with vb6 to CR11

    Do you get the error on this line

    Set crxReport = crxApp.OpenReport(ReportName)

    or this line

    .ReportSource = crxReport

  3. #3
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Re: Passing parameters with vb6 to CR11

    I am guessing these lines present the problem:
    VB Code:
    1. crxReport.ParameterFields.GetItemByName("Door Series").AddCurrentValue (CBDoorCode(CBLI))
    2. crxReport.ParameterFields.GetItemByName("Slat Type").AddCurrentValue CBSlatType(CBLI)

    is Door Series the actual name of the parameter field in your CR Report? didn't think you could have a space in paramater names.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2006
    Posts
    320

    Re: Passing parameters with vb6 to CR11

    Yes I get the error on these two lines

    VB Code:
    1. crxReport.ParameterFields.GetItemByName("Quantity").AddCurrentValue (CBQty(CBLI))
    2. crxReport.ParameterFields.GetItemByName("Distributors").AddCurrentValue CBDistributors(CBLI)

    I changed the CR11 variables to no spaces I still get the same error. I grap this data from a Query ran on an Access Data base. Not sure whats wrong here.

    Bill

  5. #5
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Re: Passing parameters with vb6 to CR11

    Yeah then it is probably something with your variables.. not sure how you are getting these:

    (CBQty(CBLI))
    CBDistributors(CBLI)

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2006
    Posts
    320

    Re: Passing parameters with vb6 to CR11

    They are 2 global variables

    VB Code:
    1. Public CBDistributors(20) As String
    2. Public CBQty(20) As Integer

    I can look at them they have good values.


    Bill

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2006
    Posts
    320

    Re: Passing parameters with vb6 to CR11

    Here you can see the values of the 2 variables in the intermediate window
    Attached Images Attached Images  

  8. #8
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Re: Passing parameters with vb6 to CR11

    Could you show me a SS of your CR design screen?

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2006
    Posts
    320

    Re: Passing parameters with vb6 to CR11

    Here it is
    Attached Images Attached Images  

  10. #10
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Re: Passing parameters with vb6 to CR11

    Sorry should have specified this... can you get me a view that has your parameter fields listed?

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2006
    Posts
    320

    Re: Passing parameters with vb6 to CR11

    Not sure just what you need to see. Here is the .rpt file
    Attached Files Attached Files

  12. #12
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Re: Passing parameters with vb6 to CR11

    Ok I think you need to change 2 things... I am assuming that your FormQuery1 is a query in Access? If so I would recommend linking the source directly to the original tables that you need info from. Then use the Select Expert to add in criteria of the data that you would like to see. If you would like to base the criteria on a parameter passed from VB then you will need to add a Parameter field. You can create a Parameter field in the Field Explorer. Paramater fields can be used in the criteria of the Select Expert.

    In the code example:

    VB Code:
    1. crxReport.ParameterFields.GetItemByName("Quantity").AddCurrentValue (CBQty(CBLI))
    2. crxReport.ParameterFields.GetItemByName("Distributors").AddCurrentValue CBDistributors(CBLI)

    Quantity and Distributors would have to be the names of the Parameter fields inside the report and used in the Select Expert to display data based on the parameters that you want to pass.

    Hope this helps... once you get it, it will seem easy.

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