I need to search a textbox for a piece of string and then store that string into a variable. For example:
If the textbox value contains "Jane Doe, John Doe (Audit ID: 0337) 01/12/1991 Scheduled", then I would like to put the Audit ID "0337" into a variable.
The textbox value will always contain one Audit ID but the other values will change.
Is this even possible?
Other people have coded to split a string so I tried manipulating the code below but couldn't get the results I wanted
I also tried the code below and was able to store a variable for characters up to the numeric value but couldn't capture the numeric value
Thank you all for your help!
If the textbox value contains "Jane Doe, John Doe (Audit ID: 0337) 01/12/1991 Scheduled", then I would like to put the Audit ID "0337" into a variable.
The textbox value will always contain one Audit ID but the other values will change.
Is this even possible?
Other people have coded to split a string so I tried manipulating the code below but couldn't get the results I wanted
Code:
Dim fullSearchString As String
Dim strWhere As String
Dim startPos As Integer
startPos = 1
fullSearchString = Me.MySearchBox.Value
strWhere = "WHERE"
For x = 0 To MaxValue
strWhere = strWhere & " Field1 LIKE '%"
strWhere = strWhere & Mid(fullSearchString, startPos, InStr(startPos, "Audit#:", fullSearchString))
strWhere = strWhere & "%' AND"
startPos = InStr(startPos, " ", fullSearchString)
Next x
strWhere = Left(strWhere, Len(strWhere) - 3) 'remove last AND
MsgBox strWhere
I also tried the code below and was able to store a variable for characters up to the numeric value but couldn't capture the numeric value
Code:
Dim i As Integer
Dim partStr As String
Dim partNum As String
For i = 1 To Len(MySearchBox)
If IsNumeric(Mid$(MySearchBox, i, 1)) Then
partStr = Left$(MySearchBox, i - 1)
partNum = Mid$(YourTextField, i)
Exit For
End If
Next
MsgBox partStr
MsgBox partNum
End Sub
Thank you all for your help!
Last edited: