How to display the value of Textbox at the same time

wendywu

New member
Local time
Tomorrow, 06:43
Joined
May 20, 2024
Messages
7
I want the SearchText to display the value of the SearchBox while typing in the SearchBox and write as follows:
Private Sub SearchBox_Change()

Me.SearchText = Me.SearchBox.Text
Me.ListResults.Requery

End Sub

But it doesn't work , what's wrong?
 
Hi. Just FYI, I moved your thread out of the Introduction forum.

What does "doesn't work" mean? Are you getting an error message?
 
What I mean is that when entering a value in SearchBox, it is not displayed in SearchText at the same time.
 
maybe check your control names again, coz when i tried it, it does change SearchText textbox.
 
After I removed this line of code, Me.ListResults.Requery
this is the code now:
Private Sub SearchBox_Change()

Me.SearchText = Me.SearchBox.Text

End Sub

It does change SearchText textbox.
Thank you!
 
That line of code should have no effect on what you are attempting? :(
 
That line of code should have no effect on what you are attempting? :(
Are you sure that the .Requery doesn't reset the focus to the text box and automatically select all the contained text, leading to the next keystroke overwriting what head previously been typed?
 
Are you sure that the .Requery doesn't reset the focus to the text box and automatically select all the contained text, leading to the next keystroke overwriting what head previously been typed?
Only the O/P can tell us that?, unless you know for certain that that happens?
They can walk the code and let us know?
 
unless you know for certain that that happens?
I've no idea, and I'm nowhere near a Windows machine to test.

Just seem to have vague recollections of needing to see .SelStart when implementing basic FAYT
 
Seems not?
1725365803614.png


Code:
Option Compare Database
Option Explicit

Private Sub txtSearch_Change()
Me.txtTyped = Me.txtSearch.Text
Me.List0.Requery
End Sub
 
That line of code should have no effect on what you are attempting? :(
I ran the same program today, and today's result is still that there is no change in SearText when I enter a value in SearchBox
 
maybe upload your db so we can see what is going on behind the scene on your form.
 

Attachments

  • 1725438590946.jpg
    1725438590946.jpg
    290.2 KB · Views: 20
  • 1725438676710.jpg
    1725438676710.jpg
    32.1 KB · Views: 16
if you are unable to upload your db, maybe try this:

Code:
Option Compare Database
Option Explicit

Private Sub SearchBox_Change()
    Dim txt As String
    txt = Me.SearchBox.Text
    Me.SearchText = txt
    Me.ListResults.Requery
    With Me.SearchBox
        .SetFocus
        .Value = txt
        .SelStart = Len(txt)
    End With
End Sub
 
see your db (note i remaned it as demo.accdb)
 

Attachments

Users who are viewing this thread

Back
Top Bottom