Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2000-04-17
4
Medium Priority
?
226 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

618 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