Get selected text from textbox as filtering string for another form

edgaro

Registered User.
Local time
Today, 00:09
Joined
Jul 11, 2015
Messages
22
Hello everyone, this is my first post here.

I hope you can help me get this working. So, I have a main form with two continuous subforms like this:
frmContratos: main form
frmContInsumos: contains new products
frmInsumos: contains existing products

I want the user to highlight a word using a double click in a textbox called DescInsumo from frmContInsumos. And I want that highlighted portion to be used as filter for frmInsumos, which also has a textbox called DescInsumo. I used this and it's giving me the word, but it doesn't work with the double click event:
Code:
Private Sub DescInsumo_Click()
Debug.Print Me.DescInsumo.SelText
End Sub

Thanks everyone, in advance.
 
How do you highlight something using a double-click?

When you double click a word in a textbox, it selects the word by shading? it. I'm not a native english speaker, please forgive me.
 
So I tested this, and a little trick you can do is start a timer, and then when the timer fires, then your selection is good. Consider this code . . .
Code:
Private Sub Text1_DblClick(Cancel As Integer)
    Debug.Print "Text is not selected yet: " & Me.Text1.SelText
    Me.TimerInterval = 100
End Sub

Private Sub Form_Timer()
    Me.TimerInterval = 0
    Debug.Print "Text is selected: " & Me.Text1.SelText
End Sub
See what is happening there? I think it should work during the double click event, but obviously it doesn't.

hth
 
See what is happening there?
I think I do, when I was testing the code (the one I posted) with the double click event, I was using a msgbox to see if it returned the text I tried to select like this:
Code:
msgbox (me.text1.seltext)
But I noticed that it triggered the msgbox first, without any text, and upon closing the msgbox, THEN the text would be selected.

What you're doing here works wonderfully, I will mark this a solved right now.

Thank you so much.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom