Solved

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

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MS Access Search and Replace Using VBA 6 85
vb6 connector to mongodb 2 122
Dinamic report to Crosstab query 9 34
Set WorkSheet  not Working 9 42
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

831 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