Results 1 to 11 of 11

Thread: making a parameter optional

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2002
    Location
    10000 light years away
    Posts
    143

    making a parameter optional

    Hi All,

    please tell me how do i make a parameter field optional? that means i have a report with a parameter as the location. if the user doesn't want to filter based on location, all the locations must be displayed. how do i do this? all help will be apreciated. (i am using CR 9 with VB 6)

    thanks in advance.
    I was gratified to be able to answer promptly. I said I don't know!

  2. #2
    Member
    Join Date
    Jan 2006
    Posts
    37

    Re: making a parameter optional

    Private Sub mysub(Byval str As string, Optional Byval str2="" As string)

    end sub



    str2 variable is declare as string whose default value is equal to a null string
    optional variable must have default value or an error is flag

  3. #3
    Member
    Join Date
    Jan 2006
    Posts
    37

    Re: making a parameter optional

    what is murphy law?

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jul 2002
    Location
    10000 light years away
    Posts
    143

    Re: making a parameter optional

    my parameter is in crystal report (parameter field).

    P.S :- Murphy's Law says "if anything can go wrong, it will!"
    I was gratified to be able to answer promptly. I said I don't know!

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

    Re: making a parameter optional

    Quote Originally Posted by rwin
    str2 variable is declare as string whose default value is equal to a null string optional variable must have default value or an error is flag
    You can have an optional parameter without declaring a default value.
    VB Code:
    1. Private Sub mysub(Byval str As string, Optional Byval str2 As string)
    2.  
    3. End sub
    4. 'that declare is just a valid as
    5. Private Sub mysub(Byval str As string, Optional Byval str2 = vbNullString As string)
    6.  
    7. End sub

  6. #6
    Hyperactive Member Mosabama's Avatar
    Join Date
    Aug 2004
    Location
    Mars
    Posts
    306

    Re: making a parameter optional

    How can I know if that parameter has been passed or not using code in the function ??
    My software never has bugs. It just develops random features.
    I RATE, YOU RATE!!!

  7. #7
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: making a parameter optional

    check for yesterday's postings about the optional parameters in vb
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Jul 2002
    Location
    10000 light years away
    Posts
    143

    Re: making a parameter optional

    I am not talking about parameters in vb functions, it is about values passed to the parameter fields of crystal report
    I was gratified to be able to answer promptly. I said I don't know!

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Jul 2002
    Location
    10000 light years away
    Posts
    143

    Re: making a parameter optional

    Anyone??
    I was gratified to be able to answer promptly. I said I don't know!

  10. #10
    Junior Member
    Join Date
    Feb 2006
    Posts
    27

    Re: making a parameter optional

    Hi,
    I have the same problem. I dont have VB and I just want to be able to do it in Crystal. Can someone please help?
    Thanks

  11. #11
    Junior Member
    Join Date
    Feb 2006
    Posts
    27

    Re: making a parameter optional

    I'm using .NET, but the code is quite familiar:
    Don't use parameters. Try to manage at runtime the selection formula like the example
    below:

    string selectFormula;

    oRpt = new ReportDocument();
    oRpt.Load(Application.StartupPath.ToString() + "\\Reportes\\ListadoPagos.rpt");
    oRpt.Refresh();
    crystalReportViewer1.ReportSource = oRpt;
    selectFormula = "{PAGOS.FechaPago} = DateTime('" + fechaDePago + "')";
    crystalReportViewer1.SelectionFormula = selectFormula;
    If you want to make it "optional" you can put the following sentence:

    If Trim(txtLocation.Text) <> "" Then
    selectFormula = "{TABLE1.Location} = '" + Trim(txtLocation.Text) + "'"
    crystalReportViewer1.SelectionFormula = selectFormula;
    End If


    Try to adjust it to your report.

    Regards,
    Tribo.

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