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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

find a string buried in a field

Status
Not open for further replies.

chiefvj

Technical User
Feb 4, 2005
73
US
Can someone point me to a thread that has code which will find a string anywhere in a field. For example, if I had a field with "AAAAAAAAAAAAAAAAAA jack aaaaaaaaaaaaaa", would Access or VB be able to find the "jack" in this field?
thx for any help
 
To find if a string exists anywhere is another string, use the Instr() function

If Instr(Me.Contents, "No Solution Yet") = 0 Then
strMsg = strMsg & "Do not forget to document ticket"
MsgBox strMsg, vbExclamation, "Invalid Data"
Me.cmdDocumentTicket.SetFocus
End If


hope this helps
 
Code:
[blue]   Dim str As String, idx As Integer
   
   str = "AAAAAAAAAAAAAAAAAA jack aaaaaaaaaaaaaa"
   [purple][b]idx[/b][/purple] = InStr(1, str, "jack")
   Debug.Print Mid(str, [purple][b]idx[/b][/purple], 4)[/blue]

Calvin.gif
See Ya! . . . . . .
 
You may also consider the Like operator.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
like "*" & [input search criteria] & "*"

Ian Mayor (UK)
Program Error
Programming is 1% coding, 50% error checking and 49% sweat as your application bombs out in front of the client.
 
Thanks...the like"*"& worked like a charm.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top