Results 1 to 4 of 4

Thread: [RESOLVED] Passing certain characters in a selection formula

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2004
    Location
    carmi,IL.
    Posts
    105

    Resolved [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 ' '
    David M. Camp

  2. #2
    Addicted Member mabbas110's Avatar
    Join Date
    Oct 2005
    Location
    Karachi , Pakistan
    Posts
    172

    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
    Thanks and Regards,

    Muhammad Abbas

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2004
    Location
    carmi,IL.
    Posts
    105

    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.
    David M. Camp

  4. #4
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    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'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width