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  

query issues - critera being ignored



 
 
Thread Tools Display Modes
  #1  
Old February 16th, 2007, 04:30 AM posted to microsoft.public.access.queries
Dave
external usenet poster
 
Posts: 2,331
Default query issues - critera being ignored

All,

Found some similar posts, but didn't help my sitaution. Any help would be
appreciated. I've got the following in query design view. The function
works and pulls in a variable from combo box. The appropriate records are
selected. What is killing me is if I add an "or" conditon. Either of the
conditions work seperately but when both exist in the query, all users
dispalyed is the outcome regardless if the variable is null or has value.
Trying to avoid wrtiing multiple queries for a form. Any thoughts? Thanks in
advance.

(WORKS)

STATUS USER
---------- --------
"COMPLETE" GetUSER("A")

(WORKS)

STATUS USER
---------- --------
"COMPLETE" Like "*" (or use a blank)


(DOES NOT WORK DISPLAYS ALL, ignores GetUSER)
---------- --------
"COMPLETE" GetUSER("A")
"COMPLETE" Like "*"
  #2  
Old February 16th, 2007, 01:38 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default query issues - critera being ignored

The criteria are not being ignored. You've basically told the query to get
all records that have a value in the USER field and have a status other than
"Complete" with the second line. That includes those in the first line of
criteria

What do you expect to see? Do you want a copy of the record to appear it
the first set of criteria and another copy of the record to appear if it
meets the second set of criteria?

Example,
Get me all males in the room and get me John Spencer (a male). So, do you
expect two copies of John Spencer to be presented to you.

IF you really need a copy of the record for each set of criteria, then you
need to look at using a UNION ALL query. Union queries cannot be built
using the query grid, but must be composed in SQL view.

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

"Dave" wrote in message
...
All,

Found some similar posts, but didn't help my sitaution. Any help would be
appreciated. I've got the following in query design view. The function
works and pulls in a variable from combo box. The appropriate records are
selected. What is killing me is if I add an "or" conditon. Either of the
conditions work seperately but when both exist in the query, all users
dispalyed is the outcome regardless if the variable is null or has value.
Trying to avoid wrtiing multiple queries for a form. Any thoughts? Thanks
in
advance.

(WORKS)

STATUS USER
---------- --------
"COMPLETE" GetUSER("A")

(WORKS)

STATUS USER
---------- --------
"COMPLETE" Like "*" (or use a blank)


(DOES NOT WORK DISPLAYS ALL, ignores GetUSER)
---------- --------
"COMPLETE" GetUSER("A")
"COMPLETE" Like "*"



  #3  
Old February 16th, 2007, 04:17 PM posted to microsoft.public.access.queries
Dave
external usenet poster
 
Posts: 2,331
Default query issues - critera being ignored

John,
I thought I would have seen all that were not complete by user if the first
line had a value for the function. If no user was present and the funciton
value was blank the query would return all that were not complete by all
users. So, your first assumption below is correct. Guess I'll have to
research union queries. I appreciate your help.

Thanks.





"John Spencer" wrote:

The criteria are not being ignored. You've basically told the query to get
all records that have a value in the USER field and have a status other than
"Complete" with the second line. That includes those in the first line of
criteria

What do you expect to see? Do you want a copy of the record to appear it
the first set of criteria and another copy of the record to appear if it
meets the second set of criteria?

Example,
Get me all males in the room and get me John Spencer (a male). So, do you
expect two copies of John Spencer to be presented to you.

IF you really need a copy of the record for each set of criteria, then you
need to look at using a UNION ALL query. Union queries cannot be built
using the query grid, but must be composed in SQL view.

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

"Dave" wrote in message
...
All,

Found some similar posts, but didn't help my sitaution. Any help would be
appreciated. I've got the following in query design view. The function
works and pulls in a variable from combo box. The appropriate records are
selected. What is killing me is if I add an "or" conditon. Either of the
conditions work seperately but when both exist in the query, all users
dispalyed is the outcome regardless if the variable is null or has value.
Trying to avoid wrtiing multiple queries for a form. Any thoughts? Thanks
in
advance.

(WORKS)

STATUS USER
---------- --------
"COMPLETE" GetUSER("A")

(WORKS)

STATUS USER
---------- --------
"COMPLETE" Like "*" (or use a blank)


(DOES NOT WORK DISPLAYS ALL, ignores GetUSER)
---------- --------
"COMPLETE" GetUSER("A")
"COMPLETE" Like "*"




  #4  
Old February 16th, 2007, 05:35 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default query issues - critera being ignored

If you want all users if the function returns blank (Null or a zero length
string?) and only the specified user if the function returns a value then a
UNION query is not the answer either.

If the USER field ALWAYS has a value and is a text field then your criteria
should probably be

Field: USER
Criteria: Like IIF(GetUser("A") & "" = "", "*", GetUser("A"))

Field: Status
Criteria: "Complete"

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

"Dave" wrote in message
...
John,
I thought I would have seen all that were not complete by user if the
first
line had a value for the function. If no user was present and the funciton
value was blank the query would return all that were not complete by all
users. So, your first assumption below is correct. Guess I'll have to
research union queries. I appreciate your help.

Thanks.





"John Spencer" wrote:

The criteria are not being ignored. You've basically told the query to
get
all records that have a value in the USER field and have a status other
than
"Complete" with the second line. That includes those in the first line
of
criteria

What do you expect to see? Do you want a copy of the record to appear it
the first set of criteria and another copy of the record to appear if it
meets the second set of criteria?

Example,
Get me all males in the room and get me John Spencer (a male). So, do
you
expect two copies of John Spencer to be presented to you.

IF you really need a copy of the record for each set of criteria, then
you
need to look at using a UNION ALL query. Union queries cannot be built
using the query grid, but must be composed in SQL view.

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

"Dave" wrote in message
...
All,

Found some similar posts, but didn't help my sitaution. Any help would
be
appreciated. I've got the following in query design view. The
function
works and pulls in a variable from combo box. The appropriate records
are
selected. What is killing me is if I add an "or" conditon. Either of
the
conditions work seperately but when both exist in the query, all users
dispalyed is the outcome regardless if the variable is null or has
value.
Trying to avoid wrtiing multiple queries for a form. Any thoughts?
Thanks
in
advance.

(WORKS)

STATUS USER
---------- --------
"COMPLETE" GetUSER("A")

(WORKS)

STATUS USER
---------- --------
"COMPLETE" Like "*" (or use a blank)


(DOES NOT WORK DISPLAYS ALL, ignores GetUSER)
---------- --------
"COMPLETE" GetUSER("A")
"COMPLETE" Like "*"






  #5  
Old February 16th, 2007, 10:55 PM posted to microsoft.public.access.queries
Dave
external usenet poster
 
Posts: 2,331
Default query issues - critera being ignored

John,

BINGO! Many many thanks! Works perfect. You just saved my sanity.

"John Spencer" wrote:

If you want all users if the function returns blank (Null or a zero length
string?) and only the specified user if the function returns a value then a
UNION query is not the answer either.

If the USER field ALWAYS has a value and is a text field then your criteria
should probably be

Field: USER
Criteria: Like IIF(GetUser("A") & "" = "", "*", GetUser("A"))

Field: Status
Criteria: "Complete"

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

"Dave" wrote in message
...
John,
I thought I would have seen all that were not complete by user if the
first
line had a value for the function. If no user was present and the funciton
value was blank the query would return all that were not complete by all
users. So, your first assumption below is correct. Guess I'll have to
research union queries. I appreciate your help.

Thanks.





"John Spencer" wrote:

The criteria are not being ignored. You've basically told the query to
get
all records that have a value in the USER field and have a status other
than
"Complete" with the second line. That includes those in the first line
of
criteria

What do you expect to see? Do you want a copy of the record to appear it
the first set of criteria and another copy of the record to appear if it
meets the second set of criteria?

Example,
Get me all males in the room and get me John Spencer (a male). So, do
you
expect two copies of John Spencer to be presented to you.

IF you really need a copy of the record for each set of criteria, then
you
need to look at using a UNION ALL query. Union queries cannot be built
using the query grid, but must be composed in SQL view.

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

"Dave" wrote in message
...
All,

Found some similar posts, but didn't help my sitaution. Any help would
be
appreciated. I've got the following in query design view. The
function
works and pulls in a variable from combo box. The appropriate records
are
selected. What is killing me is if I add an "or" conditon. Either of
the
conditions work seperately but when both exist in the query, all users
dispalyed is the outcome regardless if the variable is null or has
value.
Trying to avoid wrtiing multiple queries for a form. Any thoughts?
Thanks
in
advance.

(WORKS)

STATUS USER
---------- --------
"COMPLETE" GetUSER("A")

(WORKS)

STATUS USER
---------- --------
"COMPLETE" Like "*" (or use a blank)


(DOES NOT WORK DISPLAYS ALL, ignores GetUSER)
---------- --------
"COMPLETE" GetUSER("A")
"COMPLETE" Like "*"






 




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


All times are GMT +1. The time now is 04:14 PM.


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