Search function on listbox. (1 Viewer)

Onlylonely

Registered User.
Local time
Tomorrow, 04:10
Joined
Jan 18, 2017
Messages
43
Hi,

Am having issue on search function on the listbox.
Anyone can advise?

Code:
Private Sub txtfind_Change()

        
        Dim strSource As String
        strSource = "SELECT FirstName" & _
         "FROM Guests " & _
         "Where FirstName Like '*" & Me.txtfind.Text & "*' "
         
        Me.List0.RowSource = strSource


End Sub
 

Attachments

  • vendor.accdb
    1.3 MB · Views: 48

isladogs

MVP / VIP
Local time
Today, 20:10
Joined
Jan 14, 2017
Messages
18,186
Code:
Private Sub txtfind_Change()
        
        Dim strSource As String
     [B][/B]   strSource = "SELECT FirstName[COLOR="red"] "[/COLOR] & _
         "FROM Guests " & _
         "Where FirstName Like[COLOR="red"] "[/COLOR]*" & Me.txtfind.Text & "*[COLOR="Red"]"[/COLOR];"
         
        Me.List0.RowSource = strSource

End Sub

Single quotes should be double
Missing space after FirstName - ALWAYS enter space BEFORE or AFTER each line continuation - I prefer at start of line but it doesn't matter which - be consistent so you can spot errors

P.S. Thanks to your user name I've now got the old Roy Orbison song on my brain ;)
 
Last edited:

Onlylonely

Registered User.
Local time
Tomorrow, 04:10
Joined
Jan 18, 2017
Messages
43
Code:
Private Sub txtfind_Change()
        
        Dim strSource As String
     [B][/B]   strSource = "SELECT FirstName[COLOR="red"] "[/COLOR] & _
         "FROM Guests " & _
         "Where FirstName Like[COLOR="red"] "[/COLOR]*" & Me.txtfind.Text & "*[COLOR="Red"]"[/COLOR];"
         
        Me.List0.RowSource = strSource

End Sub

Single quotes should be double
Missing space after FirstName - ALWAYS enter space BEFORE or AFTER each line continuation - I prefer at start of line but it doesn't matter which - be consistent so you can spot errors

P.S. Thanks to your user name I've now got the old Roy Orbison song on my brain ;)

Not sure why still not able to use the find function.
May need your help to download the attachment and take a look on it.
 

isladogs

MVP / VIP
Local time
Today, 20:10
Joined
Jan 14, 2017
Messages
18,186
Post deleted - my error
 
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:10
Joined
May 7, 2009
Messages
19,169
mr.ridder the op already has a working code.
 

Attachments

  • vendor(1).zip
    42.1 KB · Views: 35

isladogs

MVP / VIP
Local time
Today, 20:10
Joined
Jan 14, 2017
Messages
18,186
arnel
You posted just after my previous comment - glad its solved
 
Last edited:

Users who are viewing this thread

Top Bottom