PDA

View Full Version : How do I find a string within a memo field


bamodeo
10-21-2003, 10:44 AM
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!

rory
11-04-2003, 04:05 AM
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



[b]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">

m1234
04-11-2004, 12:20 AM
Use the "Like" function, not the inStr function. IE:
"SELECT * FROM tblTable WHERE [TheMemoField] Like *'" & TheSearchString &
"*'"