Blank input in parameter query

G

Guest

I have set up a very simple database, basically so I can learn how to do
things before I construct a more complex one.

The simple database consist of a table with the fields "First Name",
"Surname" and "Suburb". I have created a parameter query so the user is
prompted to enter a First Name, Surname and Suburb (actually, I have gone a
step further and created a form in which this information is put into, but
that isn't important to the problem I am having).

I have a few records in my table, amoung them Bill Smith Bayswater and John
Cleary Bayswater.

When I run the query and enter "Bill" into the first name box when promted
(leaving surname and suburb blank), I get the correct record. When I enter
"John", I get the correct record. If I enter "Bill" in the first name box and
"Bayswater" in the suburb box, I get the records for Bill and John. ie I am
getting the records for everyone who has a first name of Bill and everyone
who lives in Bayswater.

What I want to get are the records for everyone who has a first name of Bill
AND lives in Bayswater.

Hope this makes sense. Any help is greatly appreciated.

PS. As you can probably tell, I am new to Access, so please be gentle.
 
G

Guest

Thanks for the response Karl.

However, if I enter the criteria on the same line in design view (ie [Enter
First Name]; [Enter Surname]; [Enter Suburb]), I need to enter the First name
AND the Surname AND the suburb for the record to be found. If I ONLY enter
First name OR Surname OR Suburb, or any combination of these, the record will
not be found. In fact, NO records will be found.

I found the solution on another website. It may be helpful for others
searching this community. What you are trying to do is allow null responses.
Normally, Access treats an empty field by not showing any records. We want it
to display all records for an empty field.

If you have a paramter query in which the user is prompted to enter the
surname, you would use [Enter Surname] as the criteria. Entering "Jones" when
prompted would retrun all records with the surname "Jones". Leaving the
dialog box blank would return NO records. If the criteria in the query is
changed to... [Enter Surname] Or Like [Enter Surname] Is Null ...ALL
records will be returned when the dialog box is left blank.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top