Select Multiple Records Within Same Field

  • Thread starter hobbit2612 via AccessMonster.com
  • Start date
H

hobbit2612 via AccessMonster.com

Hi,

I wonder whether someone can help me please.

Through the knowledge I've gained from this and other sites I'm now able to
design a query that asks the users for parameter information to return the
desired matching records. e.g. colours that match a certain colour code or if
they choose, to view all the records by returning a null value.

Could someone perhaps offers some advice on how I may go about creating a
query where the user is asked for a parameter where the can make more than
one choice within the same field. i.e. My database has a colour code field. I
would like to allow the user to be able to select say both red and purple
records out of records that have colour codes for orange, purple, green and
red.

Any help would be greatly appreciated.

Many thanks and regards

Chris
 
K

KARL DEWEY

Try this --
SELECT [YourTable].*
FROM [YourTable]
WHERE ((([Enter input criteria separated by space]) Like "*" &
[YourTable].[Text field] & "*"));
 
H

hobbit2612 via AccessMonster.com

Karl,

This works a treat.

Thanks very much for taking the time to reply and passing on your knowledge.

Regards

Chris

KARL said:
Try this --
SELECT [YourTable].*
FROM [YourTable]
WHERE ((([Enter input criteria separated by space]) Like "*" &
[YourTable].[Text field] & "*"));
[quoted text clipped - 17 lines]
 
H

hobbit2612 via AccessMonster.com

Karl,

As I said earlier, the code you gave me works a treat.

I've been playing around with this to try and get this to work where the user
doesn't select any criteria i.e. clicks 'Go' because they decide they want to
see all the data.

From similar posts I think that the answer may have something to do with
using the term 'Is Null', mind you I could be wrong.

I've tried adding this to various areas of the coding, but I can't quite get
this to work.

Have you any ideas please where I need to make the change.

Many thanks and regards

Chris

KARL said:
Try this --
SELECT [YourTable].*
FROM [YourTable]
WHERE ((([Enter input criteria separated by space]) Like "*" &
[YourTable].[Text field] & "*"));
[quoted text clipped - 17 lines]
 
K

KARL DEWEY

Try this --
SELECT [YourTable].*
FROM [YourTable]
WHERE ([Enter input criteria separated by space] Like "*" &
[YourTable].[Text field] & "*") OR ([Enter input criteria separated by space]
Is Null);

--
KARL DEWEY
Build a little - Test a little


hobbit2612 via AccessMonster.com said:
Karl,

As I said earlier, the code you gave me works a treat.

I've been playing around with this to try and get this to work where the user
doesn't select any criteria i.e. clicks 'Go' because they decide they want to
see all the data.

From similar posts I think that the answer may have something to do with
using the term 'Is Null', mind you I could be wrong.

I've tried adding this to various areas of the coding, but I can't quite get
this to work.

Have you any ideas please where I need to make the change.

Many thanks and regards

Chris

KARL said:
Try this --
SELECT [YourTable].*
FROM [YourTable]
WHERE ((([Enter input criteria separated by space]) Like "*" &
[YourTable].[Text field] & "*"));
[quoted text clipped - 17 lines]
 
H

hobbit2612 via AccessMonster.com

Karl,

That's brilliant. I copied your code in the SQL view, obviously changing the
table and field names. I'm relatively new to Access, so I changed the view to
the design view. I was pretty close with the permetations of the coding I
tried, but I missed the crucial word 'Or'.

I really appreciate your help.

Regards

Chris


KARL said:
Try this --
SELECT [YourTable].*
FROM [YourTable]
WHERE ([Enter input criteria separated by space] Like "*" &
[YourTable].[Text field] & "*") OR ([Enter input criteria separated by space]
Is Null);
[quoted text clipped - 27 lines]
 
Top