parsing query parametering

niki

axes noob 'll b big 1 day
Local time
Today, 16:04
Joined
Apr 17, 2003
Messages
66
hello,
I have a query based on a module which parses a memo field and which searches through this field for the word "Keywords:". The module code goes like this:

Public Function TheKeyWords(longText As String) As String
TheKeyWords = Mid$(longText, InStr(1, longText, "Keywords:") + 9)

End Function

My problem is that when the function doesn't find the value "Keywords:" it returns the full field.
I'd like to add a IF loop to this code which states that if "Keywords:" is not found, the function should return an empty field.
Can someone tell me how to do this?
Thank you for your help.
nico
 
Try using IIF :-

TheKeyWords = iif(IsNull(Mid$(longText, InStr(1, longText, "Keywords:") + 9)),"", Mid$(longText, InStr(1, longText, "Keywords:") + 9)
)


If a the keword is not found and a null string is returned then an empty value is passed to your variable otherwise the found string is passed back.

If a null string is not returned on no keyword found then you may have to play around a bit wiht the iif statement.

No Guarantees but I hope this helps
 

Users who are viewing this thread

Back
Top Bottom