Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Criteria question

Status
Not open for further replies.

Thant

Technical User
Joined
Dec 31, 2007
Messages
103
Location
US
Greetings,
I have been looking for an answer to this all over and am unable to find it. I have a database of patient records that I want to be able to filter by both DOB and/or Last name. I have tried

Code:
PARAMETERS DOB DateTime;
SELECT tblPatients.[Case Number], tblPatients.[Last Name], tblPatients.[First Name], tblPatients.DOB, tblPatients.Clinician, tblPatients.[Case Manager], tblPatients.[Last Authorization Date], tblPatients.[ADAP Expiration], tblPatients.[ADAP Status]
FROM tblPatients;



but when I do this it shows me all records and puts the searched criteria in the dob field for all records. All i need is a simple criteria

any ideas?
Thanks
 
The best way would be to create a little form that asks the user to enter the LastName and/or DOB and have a button on it that runs the query using those as criteria in the WHERE section of the query (which is what does the filtering a WHERE clause)

check out Forum702 and the FAQ of this forum for some examples of how to do that....

HTH

Leslie

Come join me at New Mexico Linux Fest!
 
You need a WHERE statement, so keeping it simple:

Code:
SELECT p.[Case Number], p.[Last Name], 
       p.[First Name], p.DOB, p.Clinician, 
       p.[Case Manager], p.[Last Authorization Date], 
       p.[ADAP Expiration], p.[ADAP Status]
FROM tblPatients AS p
WHERE Dob = [Enter DOB: ] AND LastName Like [Enter Name: ] & "*"

FROM tblPatients AS p : This makes p an alias for tblPatients, so the code is shorter and easier to read.

I have added parameters to the WHERE statement for this example, but it is not usually a good idea - it is usually best to build a small form to supply the parameters.



 
Thanks all that worked!!
I appreciate the help
Thant

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top