How do I find a string within a memo field

Discussion in 'Classic ASP' started by bamodeo, Oct 21, 2003.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I'm trying to find a value within a memo field of an Access database. I tried using the inStr function as follows:

    If inStr(rsProfile.Fields("Interests").Value, "football") > 0 then
    << do stuff >>
    End if

    I get an error when executing this code against "Interests" which is a memo field. If I convert the field to a text field, it works. However when I convert the field, I lose everything beyond 255 characters.

    Can someone help with the code to find a string within a memo field?

    Thanks!
     
  2. whats the error, i dont get one with my memo fields.

    i dont get the db info the way you are here though, i use either getrows or the standard way (RS.Open, sql, conn, 1, etc)

    For example, I check the info first,

    after opening the record ..

    If Not RS.EOF Then
    If ISNull(RS("Interests")) or RS("interests") = "" Then
    interests = ""
    else
    interests = RS("interests")
    end if
    ' do more code ..
    Else
    'do more code ...
    End If



    quote:Originally posted by bamodeo

    I'm trying to find a value within a memo field of an Access database. I tried using the inStr function as follows:

    If inStr(rsProfile.Fields("Interests").Value, "football") > 0 then
    << do stuff >>
    End if

    I get an error when executing this code against "Interests" which is a memo field. If I convert the field to a text field, it works. However when I convert the field, I lose everything beyond 255 characters.

    Can someone help with the code to find a string within a memo field?

    Thanks!
    </blockquote id="quote"></font id="quote">
     
  3. Use the "Like" function, not the inStr function. IE:
    "SELECT * FROM tblTable WHERE [TheMemoField] Like *'" & TheSearchString &
    "*'"
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page