String Parsing Query

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • RH

    String Parsing Query

    <SELECT name="txtServic es" size="3" multiple>
    <OPTION value="Massage" >Massage</OPTION>
    <OPTION value="Facials" >Facials</OPTION>
    <OPTION value="Wet & Dry Body Treatments">Wet &amp; Dry Body
    Treatments</OPTION>
    <OPTION value="Medical Treatments">Med ical Treatments</OPTION>
    <OPTION value="Nails, Pedicures, Manicures">Nail s, Pedicures,
    Manicures</OPTION>
    <OPTION value="Hair">Ha ir</OPTION>
    <OPTION value="Pools">P ools</OPTION>
    <OPTION value="Waxing"> Waxing</OPTION>
    <OPTION value="Make-up">Make-up</OPTION>
    <OPTION value="Aromathe rapy">Aromather apy</OPTION>
    <OPTION value="Specialt ies">Specialtie s</OPTION>
    <OPTION value="Tinting" >Tinting</OPTION>
    <OPTION value="Fitness & Nutritional Counselling">Fi tness &amp;
    Nutritional Counselling</OPTION>
    </SELECT></TD>

    Since this is a muliple select box the values are passed to the search
    string comma delimited IE: facials, hair, pools etc

    Can anyone tell me how to parse this string and then build a select
    statement whereby I can search for Facials OR Hair OR pools
    I've been searching all over and can't find anything that does just this.

    Thanks in advance



  • Curt_C [MVP]

    #2
    Re: String Parsing Query

    I suggest you take this one step at a time.
    Look at Split() to break it apart
    Look at a FOR loop to append the values.
    OR
    Just take the command delimited value and append it into the SQL directly
    with a
    "select.....whe re.....IN (" & yourValues & ")......"

    --
    Curt Christianson
    Owner/Lead Developer, DF-Software
    Site: http://www.Darkfalz.com
    Blog: http://blog.Darkfalz.com


    "RH" <rh@bloofrog.ne t> wrote in message
    news:utkYFCFOEH A.1388@TK2MSFTN GP09.phx.gbl...[color=blue]
    > <SELECT name="txtServic es" size="3" multiple>
    > <OPTION value="Massage" >Massage</OPTION>
    > <OPTION value="Facials" >Facials</OPTION>
    > <OPTION value="Wet & Dry Body Treatments">Wet &amp; Dry Body
    > Treatments</OPTION>
    > <OPTION value="Medical Treatments">Med ical Treatments</OPTION>
    > <OPTION value="Nails, Pedicures, Manicures">Nail s, Pedicures,
    > Manicures</OPTION>
    > <OPTION value="Hair">Ha ir</OPTION>
    > <OPTION value="Pools">P ools</OPTION>
    > <OPTION value="Waxing"> Waxing</OPTION>
    > <OPTION value="Make-up">Make-up</OPTION>
    > <OPTION value="Aromathe rapy">Aromather apy</OPTION>
    > <OPTION value="Specialt ies">Specialtie s</OPTION>
    > <OPTION value="Tinting" >Tinting</OPTION>
    > <OPTION value="Fitness & Nutritional Counselling">Fi tness &amp;
    > Nutritional Counselling</OPTION>
    > </SELECT></TD>
    >
    > Since this is a muliple select box the values are passed to the search
    > string comma delimited IE: facials, hair, pools etc
    >
    > Can anyone tell me how to parse this string and then build a select
    > statement whereby I can search for Facials OR Hair OR pools
    > I've been searching all over and can't find anything that does just this.
    >
    > Thanks in advance
    >
    >
    >[/color]


    Comment

    • Steven Burn

      #3
      Re: String Parsing Query

      The really dirty method would be;

      SomeString = "x, y, z"

      Do While Not Instr(1, SomeString, ",", vbTextCompare)
      MyString = StripIt(SomeStr ing)
      Response.Write MyString & "<br>"
      Loop

      Function StripIt(TheStir ng)
      Dim strTemp
      strTemp = Split(TheString , ",")
      StripIt = path(UBound(str Temp))
      End Function

      --

      Regards

      Steven Burn
      Ur I.T. Mate Group


      Keeping it FREE!


      "RH" <rh@bloofrog.ne t> wrote in message
      news:utkYFCFOEH A.1388@TK2MSFTN GP09.phx.gbl...[color=blue]
      > <SELECT name="txtServic es" size="3" multiple>
      > <OPTION value="Massage" >Massage</OPTION>
      > <OPTION value="Facials" >Facials</OPTION>
      > <OPTION value="Wet & Dry Body Treatments">Wet &amp; Dry Body
      > Treatments</OPTION>
      > <OPTION value="Medical Treatments">Med ical Treatments</OPTION>
      > <OPTION value="Nails, Pedicures, Manicures">Nail s, Pedicures,
      > Manicures</OPTION>
      > <OPTION value="Hair">Ha ir</OPTION>
      > <OPTION value="Pools">P ools</OPTION>
      > <OPTION value="Waxing"> Waxing</OPTION>
      > <OPTION value="Make-up">Make-up</OPTION>
      > <OPTION value="Aromathe rapy">Aromather apy</OPTION>
      > <OPTION value="Specialt ies">Specialtie s</OPTION>
      > <OPTION value="Tinting" >Tinting</OPTION>
      > <OPTION value="Fitness & Nutritional Counselling">Fi tness &amp;
      > Nutritional Counselling</OPTION>
      > </SELECT></TD>
      >
      > Since this is a muliple select box the values are passed to the search
      > string comma delimited IE: facials, hair, pools etc
      >
      > Can anyone tell me how to parse this string and then build a select
      > statement whereby I can search for Facials OR Hair OR pools
      > I've been searching all over and can't find anything that does just this.
      >
      > Thanks in advance
      >
      >
      >[/color]


      Comment

      • RosieO

        #4
        Re: String Parsing Query

        Thanks Curt - I've tried the second option, and while it works if you only
        have one item selected to search for, it doesn't if you have 2.

        Each field in the database only has one value, so one would be (Spa |
        Services) 99 | hair, 99 | pools, 100 | hair, 100| Manicures etc.

        If I select pools from the list, I get spa 99 & spa 100, If I select hair &
        Pools, I should get spa 99 & spa 100

        So, I've gone the other route.but what I can't figure out is how to make an
        OR statement out of the array I get when I do Split.
        (I've never done this before so I'm kindof confused with the syntax)

        From what I can dig up information wise on this, I have to use a loop to
        build an or statement that I can then pull into my query.

        How do I do that??


        Robyn




        "Curt_C [MVP]" <software_AT_da rkfalz.com> wrote in message
        news:eC0D%23IFO EHA.2524@TK2MSF TNGP11.phx.gbl. ..[color=blue]
        > I suggest you take this one step at a time.
        > Look at Split() to break it apart
        > Look at a FOR loop to append the values.
        > OR
        > Just take the command delimited value and append it into the SQL directly
        > with a
        > "select.....whe re.....IN (" & yourValues & ")......"
        >
        > --
        > Curt Christianson
        > Owner/Lead Developer, DF-Software
        > Site: http://www.Darkfalz.com
        > Blog: http://blog.Darkfalz.com
        >
        >
        > "RH" <rh@bloofrog.ne t> wrote in message
        > news:utkYFCFOEH A.1388@TK2MSFTN GP09.phx.gbl...[color=green]
        > > <SELECT name="txtServic es" size="3" multiple>
        > > <OPTION value="Massage" >Massage</OPTION>
        > > <OPTION value="Facials" >Facials</OPTION>
        > > <OPTION value="Wet & Dry Body Treatments">Wet &amp; Dry Body
        > > Treatments</OPTION>
        > > <OPTION value="Medical Treatments">Med ical Treatments</OPTION>
        > > <OPTION value="Nails, Pedicures, Manicures">Nail s, Pedicures,
        > > Manicures</OPTION>
        > > <OPTION value="Hair">Ha ir</OPTION>
        > > <OPTION value="Pools">P ools</OPTION>
        > > <OPTION value="Waxing"> Waxing</OPTION>
        > > <OPTION value="Make-up">Make-up</OPTION>
        > > <OPTION value="Aromathe rapy">Aromather apy</OPTION>
        > > <OPTION value="Specialt ies">Specialtie s</OPTION>
        > > <OPTION value="Tinting" >Tinting</OPTION>
        > > <OPTION value="Fitness & Nutritional Counselling">Fi tness[/color][/color]
        &amp;[color=blue][color=green]
        > > Nutritional Counselling</OPTION>
        > > </SELECT></TD>
        > >
        > > Since this is a muliple select box the values are passed to the search
        > > string comma delimited IE: facials, hair, pools etc
        > >
        > > Can anyone tell me how to parse this string and then build a select
        > > statement whereby I can search for Facials OR Hair OR pools
        > > I've been searching all over and can't find anything that does just[/color][/color]
        this.[color=blue][color=green]
        > >
        > > Thanks in advance
        > >
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Curt_C [MVP]

          #5
          Re: String Parsing Query

          I thought that the multi select came throug comman-delimited, but I may be
          wrong. You may have to do some simple Replace() calls to format it right

          --
          Curt Christianson
          Owner/Lead Developer, DF-Software
          Site: http://www.Darkfalz.com
          Blog: http://blog.Darkfalz.com


          "RosieO" <RosieO@mail.co m> wrote in message
          news:u$gbg7FOEH A.1276@TK2MSFTN GP11.phx.gbl...[color=blue]
          > Thanks Curt - I've tried the second option, and while it works if you only
          > have one item selected to search for, it doesn't if you have 2.
          >
          > Each field in the database only has one value, so one would be (Spa |
          > Services) 99 | hair, 99 | pools, 100 | hair, 100| Manicures etc.
          >
          > If I select pools from the list, I get spa 99 & spa 100, If I select hair[/color]
          &[color=blue]
          > Pools, I should get spa 99 & spa 100
          >
          > So, I've gone the other route.but what I can't figure out is how to make[/color]
          an[color=blue]
          > OR statement out of the array I get when I do Split.
          > (I've never done this before so I'm kindof confused with the syntax)
          >
          > From what I can dig up information wise on this, I have to use a loop to
          > build an or statement that I can then pull into my query.
          >
          > How do I do that??
          >
          >
          > Robyn
          >
          >
          >
          >
          > "Curt_C [MVP]" <software_AT_da rkfalz.com> wrote in message
          > news:eC0D%23IFO EHA.2524@TK2MSF TNGP11.phx.gbl. ..[color=green]
          > > I suggest you take this one step at a time.
          > > Look at Split() to break it apart
          > > Look at a FOR loop to append the values.
          > > OR
          > > Just take the command delimited value and append it into the SQL[/color][/color]
          directly[color=blue][color=green]
          > > with a
          > > "select.....whe re.....IN (" & yourValues & ")......"
          > >
          > > --
          > > Curt Christianson
          > > Owner/Lead Developer, DF-Software
          > > Site: http://www.Darkfalz.com
          > > Blog: http://blog.Darkfalz.com
          > >
          > >
          > > "RH" <rh@bloofrog.ne t> wrote in message
          > > news:utkYFCFOEH A.1388@TK2MSFTN GP09.phx.gbl...[color=darkred]
          > > > <SELECT name="txtServic es" size="3" multiple>
          > > > <OPTION value="Massage" >Massage</OPTION>
          > > > <OPTION value="Facials" >Facials</OPTION>
          > > > <OPTION value="Wet & Dry Body Treatments">Wet &amp; Dry Body
          > > > Treatments</OPTION>
          > > > <OPTION value="Medical Treatments">Med ical[/color][/color][/color]
          Treatments</OPTION>[color=blue][color=green][color=darkred]
          > > > <OPTION value="Nails, Pedicures, Manicures">Nail s,[/color][/color][/color]
          Pedicures,[color=blue][color=green][color=darkred]
          > > > Manicures</OPTION>
          > > > <OPTION value="Hair">Ha ir</OPTION>
          > > > <OPTION value="Pools">P ools</OPTION>
          > > > <OPTION value="Waxing"> Waxing</OPTION>
          > > > <OPTION value="Make-up">Make-up</OPTION>
          > > > <OPTION value="Aromathe rapy">Aromather apy</OPTION>
          > > > <OPTION value="Specialt ies">Specialtie s</OPTION>
          > > > <OPTION value="Tinting" >Tinting</OPTION>
          > > > <OPTION value="Fitness & Nutritional Counselling">Fi tness[/color][/color]
          > &amp;[color=green][color=darkred]
          > > > Nutritional Counselling</OPTION>
          > > > </SELECT></TD>
          > > >
          > > > Since this is a muliple select box the values are passed to the search
          > > > string comma delimited IE: facials, hair, pools etc
          > > >
          > > > Can anyone tell me how to parse this string and then build a select
          > > > statement whereby I can search for Facials OR Hair OR pools
          > > > I've been searching all over and can't find anything that does just[/color][/color]
          > this.[color=green][color=darkred]
          > > >
          > > > Thanks in advance
          > > >
          > > >
          > > >[/color]
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • RosieO

            #6
            Re: String Parsing Query

            Yes it does - should it then evaluate each piece separately as in an OR
            statement?
            Because if I just select one value, it works fine; if I select 2 it returns
            nothing.



            "Curt_C [MVP]" <software_AT_da rkfalz.com> wrote in message
            news:Odh3i9FOEH A.3712@TK2MSFTN GP10.phx.gbl...[color=blue]
            > I thought that the multi select came throug comman-delimited, but I may be
            > wrong. You may have to do some simple Replace() calls to format it right
            >
            > --
            > Curt Christianson
            > Owner/Lead Developer, DF-Software
            > Site: http://www.Darkfalz.com
            > Blog: http://blog.Darkfalz.com
            >
            >
            > "RosieO" <RosieO@mail.co m> wrote in message
            > news:u$gbg7FOEH A.1276@TK2MSFTN GP11.phx.gbl...[color=green]
            > > Thanks Curt - I've tried the second option, and while it works if you[/color][/color]
            only[color=blue][color=green]
            > > have one item selected to search for, it doesn't if you have 2.
            > >
            > > Each field in the database only has one value, so one would be (Spa |
            > > Services) 99 | hair, 99 | pools, 100 | hair, 100| Manicures etc.
            > >
            > > If I select pools from the list, I get spa 99 & spa 100, If I select[/color][/color]
            hair[color=blue]
            > &[color=green]
            > > Pools, I should get spa 99 & spa 100
            > >
            > > So, I've gone the other route.but what I can't figure out is how to make[/color]
            > an[color=green]
            > > OR statement out of the array I get when I do Split.
            > > (I've never done this before so I'm kindof confused with the syntax)
            > >
            > > From what I can dig up information wise on this, I have to use a loop to
            > > build an or statement that I can then pull into my query.
            > >
            > > How do I do that??
            > >
            > >
            > > Robyn
            > >
            > >
            > >
            > >
            > > "Curt_C [MVP]" <software_AT_da rkfalz.com> wrote in message
            > > news:eC0D%23IFO EHA.2524@TK2MSF TNGP11.phx.gbl. ..[color=darkred]
            > > > I suggest you take this one step at a time.
            > > > Look at Split() to break it apart
            > > > Look at a FOR loop to append the values.
            > > > OR
            > > > Just take the command delimited value and append it into the SQL[/color][/color]
            > directly[color=green][color=darkred]
            > > > with a
            > > > "select.....whe re.....IN (" & yourValues & ")......"
            > > >
            > > > --
            > > > Curt Christianson
            > > > Owner/Lead Developer, DF-Software
            > > > Site: http://www.Darkfalz.com
            > > > Blog: http://blog.Darkfalz.com
            > > >
            > > >
            > > > "RH" <rh@bloofrog.ne t> wrote in message
            > > > news:utkYFCFOEH A.1388@TK2MSFTN GP09.phx.gbl...
            > > > > <SELECT name="txtServic es" size="3" multiple>
            > > > > <OPTION value="Massage" >Massage</OPTION>
            > > > > <OPTION value="Facials" >Facials</OPTION>
            > > > > <OPTION value="Wet & Dry Body Treatments">Wet &amp; Dry[/color][/color][/color]
            Body[color=blue][color=green][color=darkred]
            > > > > Treatments</OPTION>
            > > > > <OPTION value="Medical Treatments">Med ical[/color][/color]
            > Treatments</OPTION>[color=green][color=darkred]
            > > > > <OPTION value="Nails, Pedicures, Manicures">Nail s,[/color][/color]
            > Pedicures,[color=green][color=darkred]
            > > > > Manicures</OPTION>
            > > > > <OPTION value="Hair">Ha ir</OPTION>
            > > > > <OPTION value="Pools">P ools</OPTION>
            > > > > <OPTION value="Waxing"> Waxing</OPTION>
            > > > > <OPTION value="Make-up">Make-up</OPTION>
            > > > > <OPTION value="Aromathe rapy">Aromather apy</OPTION>
            > > > > <OPTION value="Specialt ies">Specialtie s</OPTION>
            > > > > <OPTION value="Tinting" >Tinting</OPTION>
            > > > > <OPTION value="Fitness & Nutritional Counselling">Fi tness[/color]
            > > &amp;[color=darkred]
            > > > > Nutritional Counselling</OPTION>
            > > > > </SELECT></TD>
            > > > >
            > > > > Since this is a muliple select box the values are passed to the[/color][/color][/color]
            search[color=blue][color=green][color=darkred]
            > > > > string comma delimited IE: facials, hair, pools etc
            > > > >
            > > > > Can anyone tell me how to parse this string and then build a select
            > > > > statement whereby I can search for Facials OR Hair OR pools
            > > > > I've been searching all over and can't find anything that does just[/color]
            > > this.[color=darkred]
            > > > >
            > > > > Thanks in advance
            > > > >
            > > > >
            > > > >
            > > >
            > > >[/color]
            > >
            > >[/color]
            >
            >[/color]


            Comment

            • TomB

              #7
              Re: String Parsing Query

              What if you just did.

              SqlFieldName="F ield1"
              SomeString="x, y, z"
              SomeString=SqlF ieldName & " = '" & Replace(SomeStr ing, ", ", "' OR " &
              SqlFieldName & "='") & "'"

              Which should produce

              Field1='x' OR Field1='y' OR Field1='z'

              "Steven Burn" <pvt@noyb.com > wrote in message
              news:e$Ftc2FOEH A.1616@TK2MSFTN GP12.phx.gbl...[color=blue]
              > The really dirty method would be;
              >
              > SomeString = "x, y, z"
              >
              > Do While Not Instr(1, SomeString, ",", vbTextCompare)
              > MyString = StripIt(SomeStr ing)
              > Response.Write MyString & "<br>"
              > Loop
              >
              > Function StripIt(TheStir ng)
              > Dim strTemp
              > strTemp = Split(TheString , ",")
              > StripIt = path(UBound(str Temp))
              > End Function
              >
              > --
              >
              > Regards
              >
              > Steven Burn
              > Ur I.T. Mate Group
              > www.it-mate.co.uk
              >
              > Keeping it FREE!
              >
              >
              > "RH" <rh@bloofrog.ne t> wrote in message
              > news:utkYFCFOEH A.1388@TK2MSFTN GP09.phx.gbl...[color=green]
              > > <SELECT name="txtServic es" size="3" multiple>
              > > <OPTION value="Massage" >Massage</OPTION>
              > > <OPTION value="Facials" >Facials</OPTION>
              > > <OPTION value="Wet & Dry Body Treatments">Wet &amp; Dry Body
              > > Treatments</OPTION>
              > > <OPTION value="Medical Treatments">Med ical Treatments</OPTION>
              > > <OPTION value="Nails, Pedicures, Manicures">Nail s, Pedicures,
              > > Manicures</OPTION>
              > > <OPTION value="Hair">Ha ir</OPTION>
              > > <OPTION value="Pools">P ools</OPTION>
              > > <OPTION value="Waxing"> Waxing</OPTION>
              > > <OPTION value="Make-up">Make-up</OPTION>
              > > <OPTION value="Aromathe rapy">Aromather apy</OPTION>
              > > <OPTION value="Specialt ies">Specialtie s</OPTION>
              > > <OPTION value="Tinting" >Tinting</OPTION>
              > > <OPTION value="Fitness & Nutritional Counselling">Fi tness[/color][/color]
              &amp;[color=blue][color=green]
              > > Nutritional Counselling</OPTION>
              > > </SELECT></TD>
              > >
              > > Since this is a muliple select box the values are passed to the search
              > > string comma delimited IE: facials, hair, pools etc
              > >
              > > Can anyone tell me how to parse this string and then build a select
              > > statement whereby I can search for Facials OR Hair OR pools
              > > I've been searching all over and can't find anything that does just[/color][/color]
              this.[color=blue][color=green]
              > >
              > > Thanks in advance
              > >
              > >
              > >[/color]
              >
              >[/color]


              Comment

              • dlbjr

                #8
                Re: String Parsing Query

                SELECT ..... FROM ..... WHERE ........... IN ('" & Replace(yourVal ues ,",","','") & "')......."

                'from dlbjr

                'Unambit from meager knowledge of inane others,engender uncharted sagacity.


                Comment

                • TomB

                  #9
                  Re: String Parsing Query

                  Ok. I feel dirty. How about.....

                  SomeString="x, y, z"

                  Dim arrVals
                  arrVals=Split(S omeString, ",")

                  Dim i
                  Dim sSQL
                  sSQL="SELECT Field1, Field2 FROM tblX WHERE "
                  for i=0 to UBound(arrVals)
                  if i>0 then
                  sSQL=sSQL & " OR "
                  end if
                  sSQL=sSQL & "Field1='" & arrVals(i) & "' "
                  next



                  "Steven Burn" <pvt@noyb.com > wrote in message
                  news:e$Ftc2FOEH A.1616@TK2MSFTN GP12.phx.gbl...[color=blue]
                  > The really dirty method would be;
                  >
                  > SomeString = "x, y, z"
                  >
                  > Do While Not Instr(1, SomeString, ",", vbTextCompare)
                  > MyString = StripIt(SomeStr ing)
                  > Response.Write MyString & "<br>"
                  > Loop
                  >
                  > Function StripIt(TheStir ng)
                  > Dim strTemp
                  > strTemp = Split(TheString , ",")
                  > StripIt = path(UBound(str Temp))
                  > End Function
                  >
                  > --
                  >
                  > Regards
                  >
                  > Steven Burn
                  > Ur I.T. Mate Group
                  > www.it-mate.co.uk
                  >
                  > Keeping it FREE!
                  >
                  >
                  > "RH" <rh@bloofrog.ne t> wrote in message
                  > news:utkYFCFOEH A.1388@TK2MSFTN GP09.phx.gbl...[color=green]
                  > > <SELECT name="txtServic es" size="3" multiple>
                  > > <OPTION value="Massage" >Massage</OPTION>
                  > > <OPTION value="Facials" >Facials</OPTION>
                  > > <OPTION value="Wet & Dry Body Treatments">Wet &amp; Dry Body
                  > > Treatments</OPTION>
                  > > <OPTION value="Medical Treatments">Med ical Treatments</OPTION>
                  > > <OPTION value="Nails, Pedicures, Manicures">Nail s, Pedicures,
                  > > Manicures</OPTION>
                  > > <OPTION value="Hair">Ha ir</OPTION>
                  > > <OPTION value="Pools">P ools</OPTION>
                  > > <OPTION value="Waxing"> Waxing</OPTION>
                  > > <OPTION value="Make-up">Make-up</OPTION>
                  > > <OPTION value="Aromathe rapy">Aromather apy</OPTION>
                  > > <OPTION value="Specialt ies">Specialtie s</OPTION>
                  > > <OPTION value="Tinting" >Tinting</OPTION>
                  > > <OPTION value="Fitness & Nutritional Counselling">Fi tness[/color][/color]
                  &amp;[color=blue][color=green]
                  > > Nutritional Counselling</OPTION>
                  > > </SELECT></TD>
                  > >
                  > > Since this is a muliple select box the values are passed to the search
                  > > string comma delimited IE: facials, hair, pools etc
                  > >
                  > > Can anyone tell me how to parse this string and then build a select
                  > > statement whereby I can search for Facials OR Hair OR pools
                  > > I've been searching all over and can't find anything that does just[/color][/color]
                  this.[color=blue][color=green]
                  > >
                  > > Thanks in advance
                  > >
                  > >
                  > >[/color]
                  >
                  >[/color]


                  Comment

                  • Steven Burn

                    #10
                    Re: String Parsing Query

                    hehe, yep, that works too ;o)

                    --

                    Regards

                    Steven Burn
                    Ur I.T. Mate Group


                    Keeping it FREE!


                    "TomB" <shuckle@hotmai lXXX.com> wrote in message
                    news:O8JMOPGOEH A.268@TK2MSFTNG P11.phx.gbl...[color=blue]
                    > What if you just did.
                    >
                    > SqlFieldName="F ield1"
                    > SomeString="x, y, z"
                    > SomeString=SqlF ieldName & " = '" & Replace(SomeStr ing, ", ", "' OR " &
                    > SqlFieldName & "='") & "'"
                    >
                    > Which should produce
                    >
                    > Field1='x' OR Field1='y' OR Field1='z'
                    >
                    > "Steven Burn" <pvt@noyb.com > wrote in message
                    > news:e$Ftc2FOEH A.1616@TK2MSFTN GP12.phx.gbl...[color=green]
                    > > The really dirty method would be;
                    > >
                    > > SomeString = "x, y, z"
                    > >
                    > > Do While Not Instr(1, SomeString, ",", vbTextCompare)
                    > > MyString = StripIt(SomeStr ing)
                    > > Response.Write MyString & "<br>"
                    > > Loop
                    > >
                    > > Function StripIt(TheStir ng)
                    > > Dim strTemp
                    > > strTemp = Split(TheString , ",")
                    > > StripIt = path(UBound(str Temp))
                    > > End Function
                    > >
                    > > --
                    > >
                    > > Regards
                    > >
                    > > Steven Burn
                    > > Ur I.T. Mate Group
                    > > www.it-mate.co.uk
                    > >
                    > > Keeping it FREE!
                    > >
                    > >
                    > > "RH" <rh@bloofrog.ne t> wrote in message
                    > > news:utkYFCFOEH A.1388@TK2MSFTN GP09.phx.gbl...[color=darkred]
                    > > > <SELECT name="txtServic es" size="3" multiple>
                    > > > <OPTION value="Massage" >Massage</OPTION>
                    > > > <OPTION value="Facials" >Facials</OPTION>
                    > > > <OPTION value="Wet & Dry Body Treatments">Wet &amp; Dry Body
                    > > > Treatments</OPTION>
                    > > > <OPTION value="Medical Treatments">Med ical[/color][/color][/color]
                    Treatments</OPTION>[color=blue][color=green][color=darkred]
                    > > > <OPTION value="Nails, Pedicures, Manicures">Nail s,[/color][/color][/color]
                    Pedicures,[color=blue][color=green][color=darkred]
                    > > > Manicures</OPTION>
                    > > > <OPTION value="Hair">Ha ir</OPTION>
                    > > > <OPTION value="Pools">P ools</OPTION>
                    > > > <OPTION value="Waxing"> Waxing</OPTION>
                    > > > <OPTION value="Make-up">Make-up</OPTION>
                    > > > <OPTION value="Aromathe rapy">Aromather apy</OPTION>
                    > > > <OPTION value="Specialt ies">Specialtie s</OPTION>
                    > > > <OPTION value="Tinting" >Tinting</OPTION>
                    > > > <OPTION value="Fitness & Nutritional Counselling">Fi tness[/color][/color]
                    > &amp;[color=green][color=darkred]
                    > > > Nutritional Counselling</OPTION>
                    > > > </SELECT></TD>
                    > > >
                    > > > Since this is a muliple select box the values are passed to the search
                    > > > string comma delimited IE: facials, hair, pools etc
                    > > >
                    > > > Can anyone tell me how to parse this string and then build a select
                    > > > statement whereby I can search for Facials OR Hair OR pools
                    > > > I've been searching all over and can't find anything that does just[/color][/color]
                    > this.[color=green][color=darkred]
                    > > >
                    > > > Thanks in advance
                    > > >
                    > > >
                    > > >[/color]
                    > >
                    > >[/color]
                    >
                    >[/color]


                    Comment

                    • RosieO

                      #11
                      Re: String Parsing Query

                      eureka!!!
                      I got it

                      If TServices<>"" then
                      strServices=rep lace(TServices, ", ", "','")
                      SqlString="SELE CT display, category, name, addr1, addr2, city, provstate, country, postalzip, phone, fax, services FROM selectservices WHERE Services IN ('" & strServices & "') AND Display='"&tDis p&"' ORDER BY Name"

                      and works perfectly!!!!
                      Thanks so much!!



                      "RosieO" <RosieO@mail.co m> wrote in message news:OgVHyGGOEH A.2920@tk2msftn gp13.phx.gbl...[color=blue]
                      > Yes it does - should it then evaluate each piece separately as in an OR
                      > statement?
                      > Because if I just select one value, it works fine; if I select 2 it returns
                      > nothing.
                      >
                      >
                      >
                      > "Curt_C [MVP]" <software_AT_da rkfalz.com> wrote in message
                      > news:Odh3i9FOEH A.3712@TK2MSFTN GP10.phx.gbl...[color=green]
                      > > I thought that the multi select came throug comman-delimited, but I may be
                      > > wrong. You may have to do some simple Replace() calls to format it right
                      > >
                      > > --
                      > > Curt Christianson
                      > > Owner/Lead Developer, DF-Software
                      > > Site: http://www.Darkfalz.com
                      > > Blog: http://blog.Darkfalz.com
                      > >
                      > >
                      > > "RosieO" <RosieO@mail.co m> wrote in message
                      > > news:u$gbg7FOEH A.1276@TK2MSFTN GP11.phx.gbl...[color=darkred]
                      > > > Thanks Curt - I've tried the second option, and while it works if you[/color][/color]
                      > only[color=green][color=darkred]
                      > > > have one item selected to search for, it doesn't if you have 2.
                      > > >
                      > > > Each field in the database only has one value, so one would be (Spa |
                      > > > Services) 99 | hair, 99 | pools, 100 | hair, 100| Manicures etc.
                      > > >
                      > > > If I select pools from the list, I get spa 99 & spa 100, If I select[/color][/color]
                      > hair[color=green]
                      > > &[color=darkred]
                      > > > Pools, I should get spa 99 & spa 100
                      > > >
                      > > > So, I've gone the other route.but what I can't figure out is how to make[/color]
                      > > an[color=darkred]
                      > > > OR statement out of the array I get when I do Split.
                      > > > (I've never done this before so I'm kindof confused with the syntax)
                      > > >
                      > > > From what I can dig up information wise on this, I have to use a loop to
                      > > > build an or statement that I can then pull into my query.
                      > > >
                      > > > How do I do that??
                      > > >
                      > > >
                      > > > Robyn
                      > > >
                      > > >
                      > > >
                      > > >
                      > > > "Curt_C [MVP]" <software_AT_da rkfalz.com> wrote in message
                      > > > news:eC0D%23IFO EHA.2524@TK2MSF TNGP11.phx.gbl. ..
                      > > > > I suggest you take this one step at a time.
                      > > > > Look at Split() to break it apart
                      > > > > Look at a FOR loop to append the values.
                      > > > > OR
                      > > > > Just take the command delimited value and append it into the SQL[/color]
                      > > directly[color=darkred]
                      > > > > with a
                      > > > > "select.....whe re.....IN (" & yourValues & ")......"
                      > > > >
                      > > > > --
                      > > > > Curt Christianson
                      > > > > Owner/Lead Developer, DF-Software
                      > > > > Site: http://www.Darkfalz.com
                      > > > > Blog: http://blog.Darkfalz.com
                      > > > >
                      > > > >
                      > > > > "RH" <rh@bloofrog.ne t> wrote in message
                      > > > > news:utkYFCFOEH A.1388@TK2MSFTN GP09.phx.gbl...
                      > > > > > <SELECT name="txtServic es" size="3" multiple>
                      > > > > > <OPTION value="Massage" >Massage</OPTION>
                      > > > > > <OPTION value="Facials" >Facials</OPTION>
                      > > > > > <OPTION value="Wet & Dry Body Treatments">Wet &amp; Dry[/color][/color]
                      > Body[color=green][color=darkred]
                      > > > > > Treatments</OPTION>
                      > > > > > <OPTION value="Medical Treatments">Med ical[/color]
                      > > Treatments</OPTION>[color=darkred]
                      > > > > > <OPTION value="Nails, Pedicures, Manicures">Nail s,[/color]
                      > > Pedicures,[color=darkred]
                      > > > > > Manicures</OPTION>
                      > > > > > <OPTION value="Hair">Ha ir</OPTION>
                      > > > > > <OPTION value="Pools">P ools</OPTION>
                      > > > > > <OPTION value="Waxing"> Waxing</OPTION>
                      > > > > > <OPTION value="Make-up">Make-up</OPTION>
                      > > > > > <OPTION value="Aromathe rapy">Aromather apy</OPTION>
                      > > > > > <OPTION value="Specialt ies">Specialtie s</OPTION>
                      > > > > > <OPTION value="Tinting" >Tinting</OPTION>
                      > > > > > <OPTION value="Fitness & Nutritional Counselling">Fi tness
                      > > > &amp;
                      > > > > > Nutritional Counselling</OPTION>
                      > > > > > </SELECT></TD>
                      > > > > >
                      > > > > > Since this is a muliple select box the values are passed to the[/color][/color]
                      > search[color=green][color=darkred]
                      > > > > > string comma delimited IE: facials, hair, pools etc
                      > > > > >
                      > > > > > Can anyone tell me how to parse this string and then build a select
                      > > > > > statement whereby I can search for Facials OR Hair OR pools
                      > > > > > I've been searching all over and can't find anything that does just
                      > > > this.
                      > > > > >
                      > > > > > Thanks in advance
                      > > > > >
                      > > > > >
                      > > > > >
                      > > > >
                      > > > >
                      > > >
                      > > >[/color]
                      > >
                      > >[/color]
                      >
                      >[/color]

                      Comment

                      Working...