PDA

Click to See Complete Forum and Search --> : [RESOLVED] Displaying Report Dates


artstar
Oct 11th, 2008, 08:46 AM
Once again don't know what to do here!

In my crystal report 9, I use a record selection formula to gather the data between two Dates. I do this by using the DTpicker control on my VB6 form.

The end user picks a start date and end date from 2 dtpicker controls on the vb6 form and that information is inserted into my record selection formula which gathers all the correct records from the database by using the DateTime field in the database.

My problem is on the REPORT I want to print the start date and end date this data is for. Is there someway I can print the dtpicker.value properity on the report?

Any Ideas

Thanks

brucevde
Oct 11th, 2008, 12:34 PM
3 options.

Add some parameters to the report, set their values from the date picker controls and then print them (you could also use them in the selection formula).

Create Formula's and set their code like you seem to be doing with the Record Selection Formula.

You could utilize the ReportTitle special field. This is handy if you need to print a description of the report, typically placed in the Page Header.

artstar
Oct 13th, 2008, 10:02 AM
Option 1:
Maybe I don't understand! If I add a parameter field to the report will it not ask for a parameter to be entered? How can I insert a parameter field into the report and NOT have it ask for a parameter to be entered?

Option 2:
I do use a formula for my record selection, and it comes from 2 dtpicker controls. The problem is how do I print on the report the dtpicker1.value as start time and dtpicker2.value as end time?

Option 3:
I don't know if the ReportTitle special field would work either because this has to be a varaible it is going to change almost every time they take a report.

Maybe you could explain in a little more detail!

Thanks

brucevde
Oct 13th, 2008, 12:50 PM
What are you using in your VB app to manipulate/view the reports? Are you using the CRAXDRT object library?

artstar
Oct 13th, 2008, 12:58 PM
Yes! That is what I am using and this is for Crystal Report 9.

Thanks again.

jggtz
Oct 13th, 2008, 07:13 PM
Just define a formula field in Crystal Reports, let's name it : crTitle and place it in the desired Section

Trim("Report Title")

And in the VB6 app :

'GEnt2 is an Integer
'CRReport is the Report object
'Chr(39) is a '


For GEnt2 = 1 To CRReport.FormulaFields.Count
Select Case CRReport.FormulaFields(GEnt2).Name
Case "{@crTitle}": CRReport.FormulaFields(GEnt2).Text = "Trim(" & Chr(39) & "from: " & Format(dtpicker1,"dd/mm/yy") & " to: " & Format(dtpicker2,"dd/mm/yy") & Chr(39) & ")"
End Select
Next Gent2


By this way we can change, from vb code, any formula text we had defined inside Crystal Reports rpt

JG

artstar
Oct 14th, 2008, 07:05 AM
First, I want to thank everyones HELP! I did not use (jggtz) suggestion because I figured out a solution before I read his post. ( I do think his suggestion would probably work, I have not tried it)

But here is what I did.
In my Vb6 application I use two DTPicker controls to select a STARTDATE and an ENDDATE, this information is then inserted into a record selection formula for my crystal report.

Now on the Report itself I created 2 new formula fields one called {?StartDate} the other called {?EndDate} the formula for the {?StartDate} is Minimum ({MyDateFieldinDataBase}) and the formula for the {?EndDate} is Maximun({MyDateFieldinDataBase}) I now insert these two fields onto the Page Header and it Prints the start and end dates of what ever data is passed thru the record selection formula.

I hope this will help someone else.

jggtz
Oct 14th, 2008, 12:33 PM
One thing to consider:
What if in the vb app we select a date range, let's say Jan 1 to Jan 7
And in the table there are data from Jan 3 to Jan 7
The report title will say Jan 3 to Jan 7 instead of Jan 1 to Jan 7
Is this acceptable to you?

artstar
Oct 14th, 2008, 01:16 PM
You are correct! However, That is what I want because if the Database does not hold records starting at Jan 1 the report will show the beginning date for the data in the database.

Thank you for your concern.