[RESOLVED] Passing certain characters in a selection formula
If the data in field(Model.model) is like this Ohm's it will return an error, if I make it Ohms it works.
Is there another way I can write my selection formula to make it work?
report.RecordSelectionFormula = "{model.brandid}= " & DataCombo4.BoundText & " and {model.model}= '" & DataCombo5.Text & "'" ' String variable has to be enclosed in ' '
Re: Passing certain characters in a selection formula
u use replace function and then replease single quotation to appear two times instead of one. i think then it should work
Re: Passing certain characters in a selection formula
Still having troubles. I am using Crystal report 9.
I am using an Access database and in one of the fields, (which is a text field) I need to be able to search. Example: data in that field.
Ohm's
Polo 25"
It seems that no matter how I write the recordselection string I can only get it to work with one or the other.
This one will work for (Ohm's) but will not work for (Polo 25")
report.RecordSelectionFormula = "{model.brandid}= " & DataCombo4.BoundText & " and {model.model}= " & Chr$(34) & DataCombo5.Text & Chr$(34)
This one will work for (Polo 25") but will not work for (Ohm's)
report.RecordSelectionFormula = "{model.brandid}= " & DataCombo4.BoundText & " and {model.model}= ' " & DataCombo5.Text & " ' "
I have tried double " ' ' " and a combination of chr$(34) with " ' "
Does anyone have any Ideas?
Thank you for your help.
Re: Passing certain characters in a selection formula
Code:
report.RecordSelectionFormula = "{model.brandid}= " & DataCombo4.BoundText & _
" and {model.model}= " & Chr$(39) & Replace(DataCombo5.Text,"'","''") & Chr$(39)
The formula would evaluate to
{model.brandid}= 1 and {model.model}= 'Polo 25"'
{model.brandid}= 1 and {model.model}= 'Ohm''s'