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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with selection formula

Status
Not open for further replies.

Alira

Programmer
Mar 21, 2001
77
CA
I'm to trying to filter the report data in VB.
The report itself is getting data from the Access .mdb and without filtering works just fine...
In the selection formula I have to filter dates

I tried - &quot;{ShipByWO.Ship Date} >= #&quot; & ToDate(D1) & &quot;# And {ShipByWO.Ship Date} <= #&quot; & ToDate(D2) & &quot;#&quot;

where ToDate is a formating function I use for string - to - date formating.

I also tried &quot;{ShipByWO.Ship Date} Between #&quot; & ToDate(D1) & &quot;# And #&quot; & ToDate(D2) & &quot;#&quot;

it did not work.
I get error message &quot;Error in selection formula&quot;
Please, help me with this....
 
What version of CR?

Unless you are in V8, you have to use date literals in the following format:

Date (2000,3,26)

In v8 you have the option of passing:

#3/26/2000# Ken Hamady
Crystal Reports Training/Consulting and a
Quick Reference Guide to VB/Crystal (including ADO)
 
I'm using Crystal Reports for Visual Basic 4.6.10

then I have to format it differently..
something like
Format(D1,&quot;yyyy&quot;,&quot;mm&quot;,&quot;dd&quot;) right?
 
No, I think if you pass it in the format I described:

Date (yyyy,mm,dd)

it will work. The key is to match the Crystal formula syntax with the resulting string. You can open the report designer and put in the formula to work, and then try to match it with your string in VB. Ken Hamady
Crystal Reports Training/Consulting and a
Quick Reference Guide to VB/Crystal (including ADO)
 
Sorry, I don't get it...

now my dates look like
2001,03,21 when they're passed as an arguments
and it is not working...

do I need brackets?? and a word Date???
 
this what I get in Formula Editor
{Module.Ship Date} in &quot;2001/01/11 11:20:44.00&quot; to &quot;2001/03/07 13:12:11.00&quot;

this is what I get in my intermidiate window
{ShipByWO.Ship Date} In 2001/03/06 To 2001/03/20
or
{ShipByWO.Ship Date} In (2001/03/06) To (2001/03/20)
or
{ShipByWO.Ship Date} In '2001/03/06' To '2001/03/20'

but how to put them in double quotes?
and how to make this selection work...?
 
The string that you pass has to be a valid formula to Crystal. That means that the literal has to have the word date and parentheses. This is an actual literal in a crystal formula:

Date (2001,3,25) Ken Hamady
Crystal Reports Training/Consulting and a
Quick Reference Guide to VB/Crystal (including ADO)
 
AAAAA!!!!!!!!!!!!:)))))))
Thank you very, very much!!!!!:)))))))
It works!:)))))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top