Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

searching for a word in a string 1

Status
Not open for further replies.

mrmetal

Technical User
Jul 8, 2005
16
US
I have a string expression that is carried over to a report. If this string expression has a certain word, I would like the report to reformat a bit by adding additional lines. I have everything set except for the fact that I can't figure out how to search established string expression for a specific word.

I've searched through this forum, and the only thing I found was an InStr function, but after trying it, it didn't work. Any help on this would be appreciated.

Ed (mrmetal)
 
InStr is indeed correct. As a suggestion, if you have a problem making a line of code work how you want it to, post it.

Perhaps the code did not work because you had your Option Compare set to Binary or something.
 
How are ya mrmetal . . . . .

An example:
Code:
[blue]   Dim qSearch As String, qWord As String
   
   qSearch = "[purple][b]String Expression[/b][/purple]"
   qWord = "[purple][b]Search Word[/b][/purple]"
   
   If InStr(1, qSearch, qWord) Then
      [green]'Reformat code here[/green]
   End If[/blue]

Calvin.gif
See Ya! . . . . . .
 
Thanks,

As this was the first time trying the InStr function, it seemed very confusing. But I have it working now.
 
'instr' didn't work for me in MS Query Analyzer (SQL Server 2000). I had email address and wanted to pull domain (all characters after the '@').

I thought that this would work:

strDomain = Right$(strEmail, Len(strEmail) - InStr(1, strEmail, "@"))

ERROR MSG: 'InStr' is not a recognized function name.

I had to go with:

right(stremail,(LEN(strEMail)-CHARINDEX('@', strEMail))) as 'domain'

Anyone know if this is a TSQL vs. SQL issue?

Thanks.


 
This is a SQL vs JetSQL issue.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks. Is there a good site/reference place to investigate all of the differences. This would expedite my learning.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top