Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help required for Crystal Report Formula 1

Status
Not open for further replies.

isha

MIS
Mar 7, 2002
216
IN
I am giving the following mentioned formula for a crystal report, but it is giving the error as 'object required'.
CrystalReport1.SelectionFormula = "IsNull({tblnewvipref.date_closed})" And Date - tblnewvipref.entry_date > 30

Please help.
Thanks
 
Hi,

I am giving the following mentioned formula for a crystal report, but it is giving the error as 'object required'.
CrystalReport1.SelectionFormula = "IsNull({tblnewvipref.date_closed})" And Date - tblnewvipref.entry_date > 30


i think you have the "'s in the wrong place try this instead...

CrystalReport1.SelectionFormula = "IsNull({tblnewvipref.date_closed}) And Date - tblnewvipref.entry_date > 30"
 
I suggest you remove the Date - portion, along with the earlier reply re: "
 

>but it is giving the error as 'object required'.

When is this happening? As soon as the code flow hits the line mentioned, or a few seconds later when CR is trying to figure it out? [/b][/i][/u][sub]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
CCLINT
This happens as soon as the code flow hits the line mentioned.
If i remove the second condition and give the code as CrystalReport1.SelectionFormula = "IsNull({tblnewvipref.date_closed})"
then it is working fine.
Please advise.
 

You forgot the french brackets around the table/field name in the second condition. [/b][/i][/u][sub]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
CCLINT
When I put the french brackets and give the following code then it gives the compile error on the french bracket.
 


I don't think you're using the correct CR syntax for the date comparison. Try using the datediff function:

CrystalReport1.SelectionFormula = "IsNull({tblnewvipref.date_closed}) And (datediff(""d"", {tblnewvipref.entry_date}, CurrentDate) > 30)"



Mark
 

MarkSweetland:
In Vb no problem to compare like: Date1 - Date2
CR does not have a DateDiff - at least not in this form

isha, read the help you are getting close:

As budbeth said:
take out the extra quotations between: date_closed})" And Date

Add ones to the end of the statement

And, as I said, add the brackets.

Copy this exactly:

CrystalReport1.SelectionFormula = "IsNull({tblnewvipref.date_closed}) And Date - {tblnewvipref.entry_date} > 30"
[/b][/i][/u][sub]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 

CCLINT,

Passing the SelectionFormula string seems to be the main problem in this case but I still don't think the syntax will work on the report. Crystal Reports has no Date() function. The Date functions available in Crystal expect an argument for conversion. Date(number), Date (string), Date (dateTime), and Date (YYYY, MM, DD). It uses CurrentDate in the newer versions to return the system date and Today in older versions. Since the SelectionFormula is parsed in the Crystal Report engine, VB Date conversions and comparisons have no effect.

Another thing to keep in mind: if the Crystal Report is saved with any predetermined SelectionFormula, the SelectionFormula used in the VB code is added to the existing SelectionFormula resulting in a narrower selection scope. It does not replace the existing formula.





Mark
 
CCLINT
Thanks for your suggestions. I have tried exactly as suggested by you.
CrystalReport1.SelectionFormula =
"IsNull({tblnewvipref.date_closed}) And Date - {tblnewvipref.entry_date} > 30"
But it is giving the Runtime error '20515'
Error inm formula. Not enough arguments have been given to this function.

I have also tried as suggested by MarkSweetland and it worked.Thanks, it has solved my problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top