Returning all results (1 Viewer)

betheball

Registered User.
Local time
Today, 21:42
Joined
Feb 5, 2003
Messages
107
I have a query that returns results where department matches the department entered by the user. Is there a way to use the same query to return all results. In other words, when the user is prompted to enter their department (a numeric value), is there something they can enter that will cause the query to return all results? I have tried various wildcards with no luck.
 

marko

Registered User.
Local time
Today, 16:42
Joined
Dec 20, 2002
Messages
24
Hi!

In criteria where you ask for department type:

Like [Enter Department]

This way when he prompts you, you can type * and this way youll get all the results.

Cheers!
Marko
 

betheball

Registered User.
Local time
Today, 21:42
Joined
Feb 5, 2003
Messages
107
Thanks Marco. I always wondered why people used "LIKE". So if I understand you correctly, one must use "LIKE" to be able to use wildcards. They don't work with "=", right?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 16:42
Joined
Feb 19, 2002
Messages
43,774
I would NOT use like in this way. Like should only be used if you need to support wildcard searches. "All", isn't a wildcard search. Keep in mind that queries that use "like" can NEVER be optomized and so Access can't use any indexes, it needs to resort to the brute force method of reading EVERY record in the table to respond to the query. A better method to support "all" is to use a compound condition.

Where YourDpt = [Enter Department] Or IsNull([Enter Department])
 

Users who are viewing this thread

Top Bottom