Solved

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

Posted on 2000-04-17
4
213 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 40 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now