A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

[ Parameter Queries ] - Multiple Values for One Parameter



 
 
Thread Tools Display Modes
  #1  
Old December 8th, 2005, 10:36 PM posted to microsoft.public.access.queries
external usenet poster
 
Posts: n/a
Default [ Parameter Queries ] - Multiple Values for One Parameter

I'm trying to make a query to fetch records from a table based on a
parameter given at run time. It works fine if I only want to run the query
against one value, but how do I enter a parameter so it will several values.

For example if I have a simple table of:
tblExample
| strFirstName | strLastName |

My query would be...
Parameters [valFirstName] value;
select * from tblExample where strFirstName = [valFirstName];

Running the query I would enter "Tom" and it would return all records whose
first name is Tom. If I would like to run the query to return all people
with the first name of Tom and Ted, I couldnt enter "Tom or Ted" because it
would error out.

Any Ideas?


  #2  
Old December 8th, 2005, 10:40 PM posted to microsoft.public.access.queries
external usenet poster
 
Posts: n/a
Default [ Parameter Queries ] - Multiple Values for One Parameter

Hi Robbie

Have you put "Tom Or Ted" in the criteria section of your query?
Without the quotes....

John

"Robbie Baquiran" wrote in message
...
I'm trying to make a query to fetch records from a table based on a
parameter given at run time. It works fine if I only want to run the
query against one value, but how do I enter a parameter so it will several
values.

For example if I have a simple table of:
tblExample
| strFirstName | strLastName |

My query would be...
Parameters [valFirstName] value;
select * from tblExample where strFirstName = [valFirstName];

Running the query I would enter "Tom" and it would return all records
whose first name is Tom. If I would like to run the query to return all
people with the first name of Tom and Ted, I couldnt enter "Tom or Ted"
because it would error out.

Any Ideas?



  #3  
Old December 8th, 2005, 11:02 PM posted to microsoft.public.access.queries
external usenet poster
 
Posts: n/a
Default [ Parameter Queries ] - Multiple Values for One Parameter

If i do it directly to the query - it would return both Tom(s) and Ted(s).
But doing so would require the end user to enter design mode and manually
alter the critera... which is something i REALLY would like to avoid.

So yes that would work, but I would like to be able to use a parameter to
dynamisize this query

"John" wrote in message
...
Hi Robbie

Have you put "Tom Or Ted" in the criteria section of your query?
Without the quotes....

John

"Robbie Baquiran" wrote in message
...
I'm trying to make a query to fetch records from a table based on a
parameter given at run time. It works fine if I only want to run the
query against one value, but how do I enter a parameter so it will
several values.

For example if I have a simple table of:
tblExample
| strFirstName | strLastName |

My query would be...
Parameters [valFirstName] value;
select * from tblExample where strFirstName = [valFirstName];

Running the query I would enter "Tom" and it would return all records
whose first name is Tom. If I would like to run the query to return all
people with the first name of Tom and Ted, I couldnt enter "Tom or Ted"
because it would error out.

Any Ideas?





  #4  
Old December 8th, 2005, 11:04 PM posted to microsoft.public.access.queries
external usenet poster
 
Posts: n/a
Default [ Parameter Queries ] - Multiple Values for One Parameter

Try this kludge:
select *
from tblExample
where Instr("," & [Enter First Names with comma between] & ",", "," &
strFirstName & ",")0

This should work if a user entered "Tom,Ted,Bob"
--
Duane Hookom
MS Access MVP
--

"Robbie Baquiran" wrote in message
...
If i do it directly to the query - it would return both Tom(s) and Ted(s).
But doing so would require the end user to enter design mode and manually
alter the critera... which is something i REALLY would like to avoid.

So yes that would work, but I would like to be able to use a parameter to
dynamisize this query

"John" wrote in message
...
Hi Robbie

Have you put "Tom Or Ted" in the criteria section of your query?
Without the quotes....

John

"Robbie Baquiran" wrote in message
...
I'm trying to make a query to fetch records from a table based on a
parameter given at run time. It works fine if I only want to run the
query against one value, but how do I enter a parameter so it will
several values.

For example if I have a simple table of:
tblExample
| strFirstName | strLastName |

My query would be...
Parameters [valFirstName] value;
select * from tblExample where strFirstName = [valFirstName];

Running the query I would enter "Tom" and it would return all records
whose first name is Tom. If I would like to run the query to return all
people with the first name of Tom and Ted, I couldnt enter "Tom or Ted"
because it would error out.

Any Ideas?







  #5  
Old December 8th, 2005, 11:09 PM posted to microsoft.public.access.queries
external usenet poster
 
Posts: n/a
Default [ Parameter Queries ] - Multiple Values for One Parameter

Robbie

Enter within the criteria fied as so. [Enter First Choice] Or [Enter
Second Choice]
You can obviously call the fields whatever you want..

Regards

John


"Robbie Baquiran" wrote in message
...
If i do it directly to the query - it would return both Tom(s) and Ted(s).
But doing so would require the end user to enter design mode and manually
alter the critera... which is something i REALLY would like to avoid.

So yes that would work, but I would like to be able to use a parameter to
dynamisize this query

"John" wrote in message
...
Hi Robbie

Have you put "Tom Or Ted" in the criteria section of your query?
Without the quotes....

John

"Robbie Baquiran" wrote in message
...
I'm trying to make a query to fetch records from a table based on a
parameter given at run time. It works fine if I only want to run the
query against one value, but how do I enter a parameter so it will
several values.

For example if I have a simple table of:
tblExample
| strFirstName | strLastName |

My query would be...
Parameters [valFirstName] value;
select * from tblExample where strFirstName = [valFirstName];

Running the query I would enter "Tom" and it would return all records
whose first name is Tom. If I would like to run the query to return all
people with the first name of Tom and Ted, I couldnt enter "Tom or Ted"
because it would error out.

Any Ideas?







  #6  
Old December 8th, 2005, 11:17 PM posted to microsoft.public.access.queries
external usenet poster
 
Posts: n/a
Default [ Parameter Queries ] - Multiple Values for One Parameter

kludge: ?


"Duane Hookom" wrote in message
...
Try this kludge:
select *
from tblExample
where Instr("," & [Enter First Names with comma between] & ",", "," &
strFirstName & ",")0

This should work if a user entered "Tom,Ted,Bob"
--
Duane Hookom
MS Access MVP
--

"Robbie Baquiran" wrote in message
...
If i do it directly to the query - it would return both Tom(s) and
Ted(s). But doing so would require the end user to enter design mode and
manually alter the critera... which is something i REALLY would like to
avoid.

So yes that would work, but I would like to be able to use a parameter to
dynamisize this query

"John" wrote in message
...
Hi Robbie

Have you put "Tom Or Ted" in the criteria section of your query?
Without the quotes....

John

"Robbie Baquiran" wrote in message
...
I'm trying to make a query to fetch records from a table based on a
parameter given at run time. It works fine if I only want to run the
query against one value, but how do I enter a parameter so it will
several values.

For example if I have a simple table of:
tblExample
| strFirstName | strLastName |

My query would be...
Parameters [valFirstName] value;
select * from tblExample where strFirstName = [valFirstName];

Running the query I would enter "Tom" and it would return all records
whose first name is Tom. If I would like to run the query to return
all people with the first name of Tom and Ted, I couldnt enter "Tom or
Ted" because it would error out.

Any Ideas?









  #7  
Old December 8th, 2005, 11:23 PM posted to microsoft.public.access.queries
external usenet poster
 
Posts: n/a
Default [ Parameter Queries ] - Multiple Values for One Parameter

You rock Duane, Thanks!

"Duane Hookom" wrote in message
...
Try this kludge:
select *
from tblExample
where Instr("," & [Enter First Names with comma between] & ",", "," &
strFirstName & ",")0

This should work if a user entered "Tom,Ted,Bob"
--
Duane Hookom
MS Access MVP
--

"Robbie Baquiran" wrote in message
...
If i do it directly to the query - it would return both Tom(s) and
Ted(s). But doing so would require the end user to enter design mode and
manually alter the critera... which is something i REALLY would like to
avoid.

So yes that would work, but I would like to be able to use a parameter to
dynamisize this query

"John" wrote in message
...
Hi Robbie

Have you put "Tom Or Ted" in the criteria section of your query?
Without the quotes....

John

"Robbie Baquiran" wrote in message
...
I'm trying to make a query to fetch records from a table based on a
parameter given at run time. It works fine if I only want to run the
query against one value, but how do I enter a parameter so it will
several values.

For example if I have a simple table of:
tblExample
| strFirstName | strLastName |

My query would be...
Parameters [valFirstName] value;
select * from tblExample where strFirstName = [valFirstName];

Running the query I would enter "Tom" and it would return all records
whose first name is Tom. If I would like to run the query to return
all people with the first name of Tom and Ted, I couldnt enter "Tom or
Ted" because it would error out.

Any Ideas?









  #8  
Old December 8th, 2005, 11:30 PM posted to microsoft.public.access.queries
external usenet poster
 
Posts: n/a
Default [ Parameter Queries ] - Multiple Values for One Parameter

Hi John -

Your approach would work - but that would still limit the query restrictions
by 2 values. If the end user would like to see Tom, Ted, Bob, Billy - The
person would be SOL. The real purpose of this question was to help me
simplify a script I had which needed to fetch result sets from a view. With
Duane's approach, I can loop around a Multi Select list box's selections to
genereate a comma delimited list which would serve as the parameter to
retrieve all records in one call of the view.

Thanks though

"John" wrote in message
...
Robbie

Enter within the criteria fied as so. [Enter First Choice] Or [Enter
Second Choice]
You can obviously call the fields whatever you want..

Regards

John


"Robbie Baquiran" wrote in message
...
If i do it directly to the query - it would return both Tom(s) and
Ted(s). But doing so would require the end user to enter design mode and
manually alter the critera... which is something i REALLY would like to
avoid.

So yes that would work, but I would like to be able to use a parameter to
dynamisize this query

"John" wrote in message
...
Hi Robbie

Have you put "Tom Or Ted" in the criteria section of your query?
Without the quotes....

John

"Robbie Baquiran" wrote in message
...
I'm trying to make a query to fetch records from a table based on a
parameter given at run time. It works fine if I only want to run the
query against one value, but how do I enter a parameter so it will
several values.

For example if I have a simple table of:
tblExample
| strFirstName | strLastName |

My query would be...
Parameters [valFirstName] value;
select * from tblExample where strFirstName = [valFirstName];

Running the query I would enter "Tom" and it would return all records
whose first name is Tom. If I would like to run the query to return
all people with the first name of Tom and Ted, I couldnt enter "Tom or
Ted" because it would error out.

Any Ideas?









  #9  
Old December 9th, 2005, 02:23 AM posted to microsoft.public.access.queries
external usenet poster
 
Posts: n/a
Default [ Parameter Queries ] - Multiple Values for One Parameter

Why didn't you say you have a multi-select list box ;-)? If we knew you were
comfortable with code, other methods might work better.

Consider the generic function for this at
http://www.rogersaccesslibrary.com/O...p#Hookom,Duane.

--
Duane Hookom
MS Access MVP


"Robbie Baquiran" wrote in message
...
Hi John -

Your approach would work - but that would still limit the query
restrictions by 2 values. If the end user would like to see Tom, Ted,
Bob, Billy - The person would be SOL. The real purpose of this question
was to help me simplify a script I had which needed to fetch result sets
from a view. With Duane's approach, I can loop around a Multi Select list
box's selections to genereate a comma delimited list which would serve as
the parameter to retrieve all records in one call of the view.

Thanks though

"John" wrote in message
...
Robbie

Enter within the criteria fied as so. [Enter First Choice] Or [Enter
Second Choice]
You can obviously call the fields whatever you want..

Regards

John


"Robbie Baquiran" wrote in message
...
If i do it directly to the query - it would return both Tom(s) and
Ted(s). But doing so would require the end user to enter design mode and
manually alter the critera... which is something i REALLY would like to
avoid.

So yes that would work, but I would like to be able to use a parameter
to dynamisize this query

"John" wrote in message
...
Hi Robbie

Have you put "Tom Or Ted" in the criteria section of your query?
Without the quotes....

John

"Robbie Baquiran" wrote in message
...
I'm trying to make a query to fetch records from a table based on a
parameter given at run time. It works fine if I only want to run the
query against one value, but how do I enter a parameter so it will
several values.

For example if I have a simple table of:
tblExample
| strFirstName | strLastName |

My query would be...
Parameters [valFirstName] value;
select * from tblExample where strFirstName = [valFirstName];

Running the query I would enter "Tom" and it would return all records
whose first name is Tom. If I would like to run the query to return
all people with the first name of Tom and Ted, I couldnt enter "Tom or
Ted" because it would error out.

Any Ideas?











 




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 Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how do i set order in a multiple parameter query turkey New Users 4 May 6th, 2005 06:48 PM
cross tab report asks for parameter values eddiec General Discussion 1 April 1st, 2005 05:30 AM
How to do a parameter query with multiple values? Norm Lundquist Running & Setting Up Queries 1 October 27th, 2004 10:18 PM
Combining Parameter Queries with Results in a Form Staci Running & Setting Up Queries 3 October 11th, 2004 05:43 PM
Refresh All with parameter queries Patti General Discussion 0 August 10th, 2004 08:38 PM


All times are GMT +1. The time now is 01:41 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.