Lost With Crystal Reports

liquidspaces

Well-known member
Joined
Nov 19, 2002
Messages
74
Location
Richmond, VA
What Im trying to do should be simple I think, though Im having difficultly finding appropriate tutorials or instruction.

Ideally Id like to have the user enter in two dates, both a "From_Date" and "To_Date". I would then like to display each record that falls within that range in Crystal Reports.

Im not asking anybody to do it all for me (though if you showed me a working example I wouldnt complain), I just really need some guidance. Any book or tutorial recommendations that you might have are also very welcome.

Thanks,
Kevin
 
rep = New CrystalReport
rep.RecordSelectionFormula = "{tblName.dateColumn} >= Date(" & startDate & ") AND {tblName.dateColumn} <= Date(" & endDate & ")"

where startDate and endDate are strings in format yyyy,mm,dd

Hope this helps
 
Forgive me, but there must be something basic that I need to do to in order to get this to work. I appreciate your time and patience.

I execute this code on a button click event, and when I click it right now nothing happens. It doesnt crash, but it doesnt bring back any results either. Im positive that the date range is present in the database Im testing on.

This is the code I have right now, which is essentially just what you gave me.

Code:
Dim startDate As String
        Dim endDate As String

        startDate = txtStartDate.Text
        endDate = txtEndDate.Text

        Dim rep = New CrystalReport()
        rep.RecordSelectionFormula = "{Shipping.DATE} >= Date(" & startDate & ") AND {Shipping.DATE} <= Date(" & endDate & ")"
 
And let me ask you this:

Does the date format that I enter in the search need to match the database date format? Or is it always necessary to use yyyy/mm/dd for the Date function?

Would it be problematic if my database data format does not match the yyyy/mm/dd?
 
I guess i assumed you are already trying to use the crystalreportviewer control.
Try adding CRV.reportsource = rep.

The date format in the db shouldnt matter, however the format that is being passed to crystal must be in the previously mentioned format. Of course the type must be a date in the db. The date being passed to crystal is comma separated not "/".
 
I cant get mine to work!!

Hi this is my first post in these forums. Hello Everyone.

Im using a SQL server database and the DateReported column is a date and time field.

My code looks like this:

rpt.DataDefinition.RecordSelectionFormula = "CDate({VehicleDefect.DateReported}) >= Date(" + startDate.Year + "," + startDate.Month + "," + startDate.Day + ") AND CDate({VehicleDefect.DateReported}) <= Date(" + endDate.Year + "," + endDate.Month + "," + endDate.Day + ")"

after I had read the above posts but I get error:

Message: "Cast from string "CDate({VehicleDefect.DateReporte" to type Double is not valid."

Can somebody please asist me in making this work!!

Thanks very much

Darren
 
Back
Top