Listbox showing search results (1 Viewer)

JaxUniverse.Jack1

New member
Local time
Today, 06:04
Joined
Nov 2, 2018
Messages
1
Hey World...

My brain isnt working today.
How do I do this in my db?

I want the search in the second tab, "Page 24."

This is the video I found this on.
youtube[DOTCOM]/watch?v=3cJinHSSkuI

Below is the code in question posted from the desc. of the YT video.

Private Sub txtProperty_Change()
On Error GoTo Err_txtProperty_Change

Dim strSource As String
strSource = "SELECT OrderNumber, Address, City, ZipCode, OrderRowID " & _
"FROM tblOrders " & _
"Where address Like '*" & Me.txtProperty.Text & "*' " _
& "Or City Like '*" & Me.txtProperty.Text & "*' " _
& "Or ZipCode Like '*" & Me.txtProperty.Text & "*' " _
& "Or OrderNumber Like '*" & Me.txtProperty.Text & "*' "

Me.lstSearchResults.RowSource = strSource

Exit_txtProperty_Change:
Exit Sub
Err_txtProperty_Change:
MsgBox Err.Number & " " & Err.Description
Resume Exit_txtProperty_Change
 

Attachments

  • Alpha.accdb
    640 KB · Views: 75

JHB

Have been here a while
Local time
Today, 14:04
Joined
Jun 17, 2012
Messages
7,732
Do you want us to do it for you, or what is your problem?
In the attached database, you don't have a table "tblOrders" also you don't have a control named "txtProperty" and the same for the list.
So I confess "My brain isnt working today." :)
 

AccessBlaster

Registered User.
Local time
Today, 05:04
Joined
May 22, 2010
Messages
5,953
The code you copied from youtube is designed for a listbox search, but the form you gave as an example uses tab controls.

Sorry no bueno!

Code:
Private Sub txtProperty_Change()
On Error GoTo Err_txtProperty_Change

Dim strSource As String
strSource = "SELECT OrderNumber, Address, City, ZipCode, OrderRowID " & _
"FROM tblOrders " & _
"Where address Like '*" & Me.txtProperty.Text & "*' " _
& "Or City Like '*" & Me.txtProperty.Text & "*' " _
& "Or ZipCode Like '*" & Me.txtProperty.Text & "*' " _
& "Or OrderNumber Like '*" & Me.txtProperty.Text & "*' "

Me.lstSearchResults.RowSource = strSource

Exit_txtProperty_Change:
Exit Sub
Err_txtProperty_Change:
MsgBox Err.Number & " " & Err.Description
Resume Exit_txtProperty_Change

 

Attachments

  • Capture Tab.JPG
    Capture Tab.JPG
    46.9 KB · Views: 137

jamesandersonicb

New member
Local time
Today, 05:04
Joined
Sep 25, 2018
Messages
4
I am trying to create a form "pickpatients" with a button (newsearch) and a listbox (list2) to run a query of my Visits1 table where all my patient
 

Users who are viewing this thread

Top Bottom