SQL for List box search form (1 Viewer)

mba_110

Registered User.
Local time
Today, 08:35
Joined
Jan 20, 2015
Messages
280
Hi

I am struct with following code in below query involve 2 tables including numeric and text fields.


Code:
Option Compare Database
Option Explicit

Private Sub btnSearch_Click()
Dim SQL As String

SQL = "SELECT tblEmployees.EmpID, tblEmployees.FullName, tblEmployees.Surname, tblEmployees.Gender, tblEmployees.Nationality, tblResidentID.Resident_ID FROM tblEmployees INNER JOIN tblResidentID ON tblEmployees.EmpID = tblResidentID.ID;"
& " from tblemployees" _
& where [EmpID]"like '*" & me.txtSearch &"*' " _
& or [Fullname]"Like '*" & me.txtSearch &"*' " _
& or [Surname]"Like '*" & me.txtSearch &"*' " _
& or [Gender]"Like '*" & me.txtSearch &"*'" _
& or [Nationality] " Like '*" & me.txtSearch &"*'" _


End Sub

this is my row source for LstEmployees which is placed on frmSearch
Code:
Option Compare Database
Option Explicit

Private Sub btnSearch_Click()
Dim SQL As String

SELECT tblEmployees.EmpID, tblEmployees.FullName, tblEmployees.Surname, tblEmployees.Gender, tblEmployees.Nationality, tblResidentID.Resident_ID FROM tblEmployees INNER JOIN tblResidentID ON tblEmployees.EmpID = tblResidentID.ID;"

End Sub

One search text box on form linked to LstEmployees to filter result Similar to search box text or numbers with in above tables fields.

You kind help is required to resolve the query.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 16:35
Joined
Jul 9, 2003
Messages
16,278
I can't quite grasp the essence of your question. So I'm bumping it up maybe somebody else to have a look. But I'm thinking shouldn't "tblResidentID" also be in the from statement?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 23:35
Joined
May 7, 2009
Messages
19,230
remove tbe semi colon :)) on your first SQL string
 

MarkK

bit cruncher
Local time
Today, 08:35
Joined
Mar 17, 2004
Messages
8,180
Also, this looks a lot like another thread you can find here, which may provide you with more ideas about how to do what you are doing.
hth
Mark
 

Users who are viewing this thread

Top Bottom