Hi cuok,
I'm not sure about what you want. Have assumed that "txtgetmed" is the control with the highlighted text that you want to search for in the memo field "txtDetail".
Place this in the Declarations section of your form:
Dim strSelection As String
This in the On MouseUp event of the Control "txtgetmed":
strSelection = Me!txtgetmed.SelText
Place this in the On Click event of a Form:
Dim ctlTextToSearch As Control, strFind As String, intFind As Integer
If IsNothing(strSelection) Then Exit Sub
Set ctlTextToSearch = Me!txtDetail
ctlTextToSearch.SetFocus
With ctlTextToSearch
strFind = strSelection
intFind = InStr(.Value, strFind)
.SetFocus
.SelStart = intFind - 1
.SelLength = Len(strFind)
End With
This is in my opinion a better Function than IsNull, palce this in a Module:
IsNothing = False
Select Case varType(varV)
Case vbEmpty
IsNothing = True
Case vbNull
IsNothing = True
Case vbString
If Len(varV) = 0 Then
IsNothing = True
End If
Case Else
IsNothing = False
End Select
This should find the 1st instance of the text selected in "txtDetail" in the Memo Field "txtDetail". If you want to find all instances, if any, please let me know. As I said, I am a little unsure. Also, if I've got it wrong also let me know, but please give a bit more info on what you want.
I'm not going to be able to do much more tipping from now on as I've actually got a job, so could if there is anything else I can help on, let me know by the weekend.
Bill