|
-
Jan 25th, 2006, 02:02 AM
#1
Thread Starter
Addicted Member
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!
-
Jan 25th, 2006, 04:11 AM
#2
Member
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
-
Jan 25th, 2006, 04:12 AM
#3
Member
Re: making a parameter optional
-
Jan 25th, 2006, 04:33 AM
#4
Thread Starter
Addicted Member
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!
-
Jan 25th, 2006, 06:40 AM
#5
Re: making a parameter optional
 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
-
Jan 25th, 2006, 06:43 AM
#6
Hyperactive Member
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!!!
-
Jan 25th, 2006, 07:08 AM
#7
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.
-
Jan 26th, 2006, 11:48 PM
#8
Thread Starter
Addicted Member
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!
-
Feb 1st, 2006, 03:59 AM
#9
Thread Starter
Addicted Member
Re: making a parameter optional
I was gratified to be able to answer promptly. I said I don't know!
-
Feb 1st, 2006, 07:38 PM
#10
Junior Member
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
-
Feb 5th, 2006, 08:43 PM
#11
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|