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  

Can anyone translate this SQL statement for me?



 
 
Thread Tools Display Modes
  #1  
Old July 2nd, 2008, 09:36 PM posted to microsoft.public.access.queries
tmwilkin
external usenet poster
 
Posts: 8
Default Can anyone translate this SQL statement for me?

Something in this below query is not returning all the values I need, so I
need to examine it a bit further to see what it is doing. I don't know IIf
statements in SQL too well, so any translation of the below would be very
helpful.

IIf(IIf([CRMAST]![Points_Owned] And [CRMAST_1]![Points_Owned],[T4: Agg
Sales]![Total
Points]-[CRMAST]![Points_Owned]-[CRMAST_1]![Points_Owned],IIf([CRMAST]![Points_Owned],[T4:
Agg Sales]![Total
Points]-[CRMAST]![Points_Owned],IIf([CRMAST_1]![Points_Owned],[T4: Agg
Sales]![Total Points]-[CRMAST_1]![Points_Owned],[T4: Agg Sales]![Total
Points])))0,0,1)

I really just can't figure out the beginning AND part of
"IIf([CRMAST]![Points_Owned] And [CRMAST_1]![Points_Owned]". To me this says
if valueX from table1 and valueX from table2... but doesn't give a condition,
such as = or .

Thanks for any help!
Todd
  #2  
Old July 2nd, 2008, 10:25 PM posted to microsoft.public.access.queries
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default Can anyone translate this SQL statement for me?

In VBA, True is usually defined as -1 and False as 0, but in actual fact,
any non-zero value will be treated as True.

Assuming [Points_Owned] is a numeric field, the IIf statement will execute
the True portion if both [CRMAST]![Points_Owned] And
[CRMAST_1]![Points_Owned] are non-zero, and the False portion if either (or
both) are zero.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"tmwilkin" wrote in message
...
Something in this below query is not returning all the values I need, so I
need to examine it a bit further to see what it is doing. I don't know
IIf
statements in SQL too well, so any translation of the below would be very
helpful.

IIf(IIf([CRMAST]![Points_Owned] And [CRMAST_1]![Points_Owned],[T4: Agg
Sales]![Total
Points]-[CRMAST]![Points_Owned]-[CRMAST_1]![Points_Owned],IIf([CRMAST]![Points_Owned],[T4:
Agg Sales]![Total
Points]-[CRMAST]![Points_Owned],IIf([CRMAST_1]![Points_Owned],[T4: Agg
Sales]![Total Points]-[CRMAST_1]![Points_Owned],[T4: Agg Sales]![Total
Points])))0,0,1)

I really just can't figure out the beginning AND part of
"IIf([CRMAST]![Points_Owned] And [CRMAST_1]![Points_Owned]". To me this
says
if valueX from table1 and valueX from table2... but doesn't give a
condition,
such as = or .

Thanks for any help!
Todd



  #3  
Old July 2nd, 2008, 10:31 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 2,364
Default Can anyone translate this SQL statement for me?

The assumption would be that those two fields are boolean (yes/no)
fields. So if both are true then the expression is true, otherwise the
expression is false.

That could be written more clearly as
CRMAST.Points_Owned = True and CRMAST_1.PointsOwned = True,
However as written it should work.



'================================================= ===
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'================================================= ===


tmwilkin wrote:
Something in this below query is not returning all the values I need, so I
need to examine it a bit further to see what it is doing. I don't know IIf
statements in SQL too well, so any translation of the below would be very
helpful.

IIf(IIf([CRMAST]![Points_Owned] And [CRMAST_1]![Points_Owned],[T4: Agg
Sales]![Total
Points]-[CRMAST]![Points_Owned]-[CRMAST_1]![Points_Owned],IIf([CRMAST]![Points_Owned],[T4:
Agg Sales]![Total
Points]-[CRMAST]![Points_Owned],IIf([CRMAST_1]![Points_Owned],[T4: Agg
Sales]![Total Points]-[CRMAST_1]![Points_Owned],[T4: Agg Sales]![Total
Points])))0,0,1)

I really just can't figure out the beginning AND part of
"IIf([CRMAST]![Points_Owned] And [CRMAST_1]![Points_Owned]". To me this says
if valueX from table1 and valueX from table2... but doesn't give a condition,
such as = or .

Thanks for any help!
Todd

 




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 02:42 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.