?
Solved

Parameter field("From Date" & "To Date") in Crystal report

Posted on 2000-04-17
4
Medium Priority
?
229 Views
Last Modified: 2012-06-21
I would like to put parameter field in my report so that user can able to select date range("From Date" and "To Date") in report whenever he wants.

Thanks for your time in advance.

LEt me know as soon as possible.

Thanks,
bhavesh55
0
Comment
Question by:bhavesh55
  • 2
4 Comments
 
LVL 6

Accepted Solution

by:
Marine earned 120 total points
ID: 2724664
Ok it should be something like this. You create 2 parameters using Command Object. You might have a statement already that looks like this.


cmd.commandtext="SELECT <fieldname>,<fieldname2> From <tablename> WHERE <fieldname> BETWEEN ? AND ?"
Then you create parameters.
cmd.CreateParameter ,adDateTime,adParamInput
cmd.CreateParameter ,adDateTime,adParamInput
cmd.Parameters(0) = text1.text
cmd.Parameters(1) = text1.text
cmd.Execute.

I didn't test it. I don't remember if that constant is correct for DateTime. If not replace it with the correct one. Post more if you get errors.

0
 
LVL 6

Expert Comment

by:Marine
ID: 2724672
um, btw you have to create connection before using command object i assumed that connection has been already defined. then cmd.activeconnection = <yourconnection>. this should be the line before you create parameters.
0
 
LVL 4

Expert Comment

by:gcs001
ID: 2725321
You can use the SelectionForumula or ReplaceSelectionFormula properties on the Crystal Report Control in VB.
If you've added the CR control to your VB project you can then pass the dates a user wants the report for as follows:

Report1.SelectionFormula("{table1.date} >= date(" & Format(Text1.Text,"yyyy,mm,dd") & ") and {table1.date} <= date(" & Format(Text2.Text,"yyyy,mm,dd") & ")")

Text1 and Text2 can be text boxes in your VB app that the user enters that start and end dates for the report.
{table1.date} is the table name and field name used in your Crystal Report.

Hope this helps.

Regards,
Grant.
0
 

Author Comment

by:bhavesh55
ID: 2745969
I am talking about crystal report only.

anyway, thanks for your help.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month14 days, 19 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question