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.
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
Re: making a parameter optional
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!"
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:
Private Sub mysub(Byval str As string, Optional Byval str2 As string)
End sub
'that declare is just a valid as
Private Sub mysub(Byval str As string, Optional Byval str2 = vbNullString As string)
End sub
Re: making a parameter optional
How can I know if that parameter has been passed or not using code in the function ??
Re: making a parameter optional
check for yesterday's postings about the optional parameters in vb
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
Re: making a parameter optional
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
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.