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 » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Query Problem



 
 
Thread Tools Display Modes
  #1  
Old February 22nd, 2010, 06:08 PM posted to microsoft.public.access.gettingstarted
Bre-x
external usenet poster
 
Posts: 103
Default Query Problem

Hi,
I have this query but is not working.

SELECT
BKAR_INV_NUM,
BKAR_INV_SONUM,
BKAR_INV_INVCD,
BKAR_INV_INVDTE,
BKAR_INV_CUSCOD
FROM BKARINV
WHERE (((BKAR_INV_INVCD)=' ') AND ((BKAR_INV_CUSCOD)="SCOENE0100")) OR
((BKAR_INV_INVCD)="X"));

I need it to show all records for SCOENE0100 that the BKAR_INV_INVCD are
either "X" or " "

Thank you all


  #2  
Old February 22nd, 2010, 06:31 PM posted to microsoft.public.access.gettingstarted
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Query Problem

On Mon, 22 Feb 2010 11:08:04 -0700, "Bre-x" wrote:

Hi,
I have this query but is not working.

SELECT
BKAR_INV_NUM,
BKAR_INV_SONUM,
BKAR_INV_INVCD,
BKAR_INV_INVDTE,
BKAR_INV_CUSCOD
FROM BKARINV
WHERE (((BKAR_INV_INVCD)=' ') AND ((BKAR_INV_CUSCOD)="SCOENE0100")) OR
((BKAR_INV_INVCD)="X"));

I need it to show all records for SCOENE0100 that the BKAR_INV_INVCD are
either "X" or " "

Thank you all


Access trims trailing blanks, so (unless you've gone to some pretty extreme
lenghts) BKAR_INV_INVCD will never equal a single blank character; in
addition, unless you have changed the default Allow Zero Length property on
the field, it won't contain an empty string "" either: it will be NULL.

Try

WHERE (((BKAR_INV_INVCD)='X" OR (BKAR_INV_INVCD) IS NULL) AND
((BKAR_INV_CUSCOD)="SCOENE0100"))

or, more compactly,

WHERE ((NZ(BKAR_INV_INVCD, "X")="X") AND ((BKAR_INV_CUSCOD)="SCOENE0100"))

--

John W. Vinson [MVP]
  #3  
Old February 22nd, 2010, 07:41 PM posted to microsoft.public.access.gettingstarted
Bre-x
external usenet poster
 
Posts: 103
Default Query Problem

Thanks!!!


"John W. Vinson" wrote in message
...
On Mon, 22 Feb 2010 11:08:04 -0700, "Bre-x" wrote:

Hi,
I have this query but is not working.

SELECT
BKAR_INV_NUM,
BKAR_INV_SONUM,
BKAR_INV_INVCD,
BKAR_INV_INVDTE,
BKAR_INV_CUSCOD
FROM BKARINV
WHERE (((BKAR_INV_INVCD)=' ') AND ((BKAR_INV_CUSCOD)="SCOENE0100")) OR
((BKAR_INV_INVCD)="X"));

I need it to show all records for SCOENE0100 that the BKAR_INV_INVCD are
either "X" or " "

Thank you all


Access trims trailing blanks, so (unless you've gone to some pretty
extreme
lenghts) BKAR_INV_INVCD will never equal a single blank character; in
addition, unless you have changed the default Allow Zero Length property
on
the field, it won't contain an empty string "" either: it will be NULL.

Try

WHERE (((BKAR_INV_INVCD)='X" OR (BKAR_INV_INVCD) IS NULL) AND
((BKAR_INV_CUSCOD)="SCOENE0100"))

or, more compactly,

WHERE ((NZ(BKAR_INV_INVCD, "X")="X") AND ((BKAR_INV_CUSCOD)="SCOENE0100"))

--

John W. Vinson [MVP]



 




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 01:27 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.