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

Using like in SelectionFormula

Status
Not open for further replies.

ajayas

Programmer
Sep 22, 2001
20
0
0
IN
Hello everybody,
I have four search criteria in my report.
I want to use 'like' clause at run time from vb6.
The report goes like this.
It has cash receipts(cr1,cr2..), bank receipts(br1,br2...) and cash payments(cp1,cp2....).The field is a string type.
I used the following:
cr.selectionformula="{table.fieldname} like 'cr*'"
but that doesnt work.
the same thing when i worked directly from report it worked. But in vb it gives error in selection formula.
Help.
thank you.
 
I've never used like, I am under the impression that it returns True or False only.

Try using left(fieldname,2)="CR" and you should get all you cash receipts. You can also prompt the user for CR, BR, CP ar All and out in a record selction formula like this:

If {?Parmfield} = "CR" then left{{fieldname},2)="CR" else
if {?Parmfield} = "BR" then left{{fieldname},2)="BR" else
if {?Parmfield} = "CP" then left{{fieldname},2)="CP"

and you should get what you want.


Software Support for Sage Mas90, Macola, Crystal Reports, Goldmine and MS Office
 
THANKS dgillz
i did as u said.
used the parameter field.
in the record selection i added the code as u suggested.
but again in vb when i run the app i used the below code.
chkcr is a check box.

If chkcr.Value = 1 Then
cr.ParameterFields(0) = "{?Parmfield} = 'CR'"
End If
is this correct?coz in help i found this:
cr.ParameterFields(0) = par1;CR;TRUE
but that doesnt work.

I m very near to what i want as u suggested.but please a little more help can solve the problem.


 
ajayas-

I do not know VB but the ogic I gave you shoul be pretty sound. Maybe someone else in the forum that knows VB will chime in? Software Support for Sage Mas90, Macola, Crystal Reports, Goldmine and MS Office
 
Perhaps this will work

cr.selectionformula="{table.fieldname} like 'cr%'"

use % instead of *
 
Thank you Ngolem
i tried that, but doesnt work.
the suggestion that dgillz gave worked quite well,
the only thing what i didnt want was to prompt the user to select the type ie cr,br,etc.
but its ok now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top