dbTalk Databases Forums  

Query Question

comp.database.ms-access comp.database.ms-access


Discuss Query Question in the comp.database.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Matthew Braumiller
 
Posts: n/a

Default Query Question - 10-02-2003 , 08:37 AM






Greetings:
Is it possible to write a query which allows the user to specify
multiple criteria for the records to be returned?

What I mean is, say I have a table with fields of "A", "B", and "C",
which containts 5,000 records. Let's say that field A is a last name
field. Is it possible to write a query where the user can input
multiple last names (3 on one use, 7 on another, 13 on the next, ect.)
so that the records returned match the last names specified?

Thanks for you time!


Reply With Quote
  #2  
Old   
Gary Floam
 
Posts: n/a

Default Re: Query Question - 10-02-2003 , 10:15 AM






Sure you can do that. The easies way is to create a table of the last names
selected, and join that table into the query definition.

If you write your own SQL, you can create a string something like
where LastName in ("Smith", "Jones", "Brown")

Good luck


"Matthew Braumiller" <matt (AT) dwminc (DOT) com> wrote

Quote:
Greetings:
Is it possible to write a query which allows the user to specify
multiple criteria for the records to be returned?

What I mean is, say I have a table with fields of "A", "B", and "C",
which containts 5,000 records. Let's say that field A is a last name
field. Is it possible to write a query where the user can input
multiple last names (3 on one use, 7 on another, 13 on the next, ect.)
so that the records returned match the last names specified?

Thanks for you time!




Reply With Quote
  #3  
Old   
Matthew Braumiller
 
Posts: n/a

Default Re: Query Question - 10-03-2003 , 09:44 AM



On Thu, 2 Oct 2003, "Gary Floam" <floam (AT) comcast (DOT) net> wrote:

Quote:
Sure you can do that. The easies way is to create a table of the last names
selected, and join that table into the query definition.

If you write your own SQL, you can create a string something like
where LastName in ("Smith", "Jones", "Brown")

Good luck


"Matthew Braumiller" <matt (AT) dwminc (DOT) com> wrote in message
news:t5aonvc67p2j01etitk969hp9j8dlaoh0k (AT) 4ax (DOT) com...
Greetings:
Is it possible to write a query which allows the user to specify
multiple criteria for the records to be returned?

What I mean is, say I have a table with fields of "A", "B", and "C",
which containts 5,000 records. Let's say that field A is a last name
field. Is it possible to write a query where the user can input
multiple last names (3 on one use, 7 on another, 13 on the next, ect.)
so that the records returned match the last names specified?

Thanks for you time!
I don't think I have explained myself very well. I'm sorry for the
confusion. I am trying to write a query for a report.

I have a table with fields A, B, C, D, E with 5,000 records.

Field A is a text field used for last name.

My users need to be able to pull up a report based on a variable
number of last names. In other words, they might need to pull up 16
last names on one report and 4 on the next; 32 on the one after that
and so on.

Is there a way to write the query so that the last statement
SELECT tblCust.*, tblCust.A
FROM tblCust
WHERE (((tblCust.A)=[Enter Last Name]));
allows the user to specify multiple last names?

I hope this is more clear.

Thanks!



Reply With Quote
  #4  
Old   
Ira Solomon
 
Posts: n/a

Default Re: Query Question - 10-04-2003 , 11:07 AM



On Fri, 03 Oct 2003 10:44:18 -0400, Matthew Braumiller
<matt (AT) dwminc (DOT) com> wrote:

Quote:
On Thu, 2 Oct 2003, "Gary Floam" <floam (AT) comcast (DOT) net> wrote:

Sure you can do that. The easies way is to create a table of the last names
selected, and join that table into the query definition.

If you write your own SQL, you can create a string something like
where LastName in ("Smith", "Jones", "Brown")

Good luck


"Matthew Braumiller" <matt (AT) dwminc (DOT) com> wrote in message
news:t5aonvc67p2j01etitk969hp9j8dlaoh0k (AT) 4ax (DOT) com...
Greetings:
Is it possible to write a query which allows the user to specify
multiple criteria for the records to be returned?

What I mean is, say I have a table with fields of "A", "B", and "C",
which containts 5,000 records. Let's say that field A is a last name
field. Is it possible to write a query where the user can input
multiple last names (3 on one use, 7 on another, 13 on the next, ect.)
so that the records returned match the last names specified?

Thanks for you time!

I don't think I have explained myself very well. I'm sorry for the
confusion. I am trying to write a query for a report.

I have a table with fields A, B, C, D, E with 5,000 records.

Field A is a text field used for last name.

My users need to be able to pull up a report based on a variable
number of last names. In other words, they might need to pull up 16
last names on one report and 4 on the next; 32 on the one after that
and so on.

Is there a way to write the query so that the last statement
SELECT tblCust.*, tblCust.A
FROM tblCust
WHERE (((tblCust.A)=[Enter Last Name]));
allows the user to specify multiple last names?

I hope this is more clear.

Thanks!
Matthew:

Gary's answer is the right way to do this.
In the front end create a table called Qnames.
Create a form based on qnames.
User opens form, enters names he wants.
The query is set up as Gary suggested linking Qnames to the main table
by the Name field.
Next time the user wants to run it he just edits the names and runs
the query. (You might want a delete all option in the form.)

As the table is in the front end, no user interferes with another.

As for your second question.
If you use an SQL-Server back end as opposed to Access, you can do 2
things to improve query performance.

1. Used stored procedures in the SQL db.
2. Use pass-through queries.

both of the above require quite a bit of work and you will need to
look them up in a good book or on the net.

Good Luck
Ira Solomon






Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.