Results 1 to 5 of 5

Thread: Two Parameters

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2005
    Location
    Newtown, UK
    Posts
    3

    Two Parameters

    Right i've followed a guide and got a VB program working with Crystal Reports. So i added my own report and that worked ok.

    Now i want to pass two parameters to the report. This is where i need help, i've googled but can't find any guides/samples that pass two parameters e.g. Date and Supplier.

    Below is the code for passing just one parameter. Anyone able to modify it so i can pass two. Thanks

    VB Code:
    1. Imports CrystalDecisions.Shared
    2. Public Class Form1
    3. Inherits System.Windows.Forms.Form
    4.  
    5. #Region " Windows Form Designer generated code "
    6.  
    7.  
    8. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    9. CrystalReportViewer1.DisplayGroupTree = False
    10. CrystalReportViewer1.ShowPrintButton = True
    11. End Sub
    12.  
    13. Private Sub Button1_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    14.  
    15. Dim myParameterFields As New ParameterFields
    16. Dim myParameterField As New ParameterField
    17. Dim myDiscreteValue As New ParameterDiscreteValue
    18.  
    19. myParameterField.ParameterFieldName = "DataDate"
    20. myDiscreteValue.Value = DateTimePicker1.Text
    21. myParameterField.CurrentValues.Add(myDiscreteValue )
    22.  
    23. myParameterFields.Add(myParameterField)
    24.  
    25. CrystalReportViewer1.ParameterFieldInfo = myParameterFields
    26.  
    27. CrystalReportViewer1.ReportSource = New CCReport
    28. CrystalReportViewer1.Refresh()
    29.  
    30. End Sub
    31. End Class

    I've tried passing two parameters but only one seems to work. Sorry but i'm a bit of a newbie to both Crystal Reports and VB

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Two Parameters

    This should help.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2005
    Location
    Newtown, UK
    Posts
    3

    Re: Two Parameters

    Thanks for the reply.

    I've had a look at that thread but not sure how to mod my code to allow the second parameter.

    Sorry for being such a newbie.

    Should i of said i'm trying to do an windows application not Web site
    Last edited by [ego]mouse; Feb 1st, 2005 at 09:19 AM.

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Two Parameters

    Not a prob. I havent used CR in .NET yet, but I will try. You can .Add the
    first parameter to the Parameters collection. You can access them by doing
    something like...

    VB Code:
    1. myParameterFields.Items(1).ClearCurrentValueAndRange
    2. myParameterFields.Items(1).Add strValue1
    3. myParameterFields.Items(2).ClearCurrentValueAndRange
    4. myParameterFields.Items(2).Add strValue2
    I think something like this will work for you. In the link I posted the post that
    is most relevant is #11.

    HTH
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2005
    Location
    Newtown, UK
    Posts
    3

    Re: Two Parameters

    God i hate VB hehehehe.

    Still no joy. Is there anyone that actual codes VB with Crystal Reports in them. Looks like i may have to pay someone to do it.

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