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  

Switch



 
 
Thread Tools Display Modes
  #1  
Old January 1st, 2010, 10:55 PM posted to microsoft.public.access.queries
shank
external usenet poster
 
Posts: 113
Default Switch

Not getting the results I expect from the below Switch Function.

Given:
[TQM]![acb] = -1529
[TQM]![qstq] = 12261

AOD:
Switch([TQM]![acb]-[TQM]![qstq]=0,1,
([TQM]![acb]-[TQM]![qstq]*-1)[TQM]![qstq],2,
(([TQM]![acb]-[TQM]![qstq])*-1)[TQM]![qstq],3)

Result is AOD = 3

Not making sense... (-1529 - 12261)*-1 is not less than 12261

What am I missing?
thanks!


  #2  
Old January 2nd, 2010, 03:43 AM posted to microsoft.public.access.queries
theDBguy
external usenet poster
 
Posts: 1
Default Switch

Hi shank,

I type the following in the Immediate window and got Null as a result:

?switch(-1529-12261=0,1,(-1529-12261*-1)12261,2,((-1529-12261)*-1)12261,3)
Null

Did I miss something?


"shank" wrote:

Not getting the results I expect from the below Switch Function.

Given:
[TQM]![acb] = -1529
[TQM]![qstq] = 12261

AOD:
Switch([TQM]![acb]-[TQM]![qstq]=0,1,
([TQM]![acb]-[TQM]![qstq]*-1)[TQM]![qstq],2,
(([TQM]![acb]-[TQM]![qstq])*-1)[TQM]![qstq],3)

Result is AOD = 3

Not making sense... (-1529 - 12261)*-1 is not less than 12261

What am I missing?
thanks!


.

  #3  
Old January 2nd, 2010, 04:31 AM posted to microsoft.public.access.queries
Marshall Barton
external usenet poster
 
Posts: 5,361
Default Switch

shank wrote:

Not getting the results I expect from the below Switch Function.

Given:
[TQM]![acb] = -1529
[TQM]![qstq] = 12261

AOD:
Switch([TQM]![acb]-[TQM]![qstq]=0,1,
([TQM]![acb]-[TQM]![qstq]*-1)[TQM]![qstq],2,
(([TQM]![acb]-[TQM]![qstq])*-1)[TQM]![qstq],3)

Result is AOD = 3

Not making sense... (-1529 - 12261)*-1 is not less than 12261

What am I missing?



I think you are missing a set of parensthesis in the second
condition.

OTOH, your condition expressions are not intuitive to me.
Assuming that condition 2 was supposed to be:
(([TQM]![acb]-[TQM]![qstq])*-1)[TQM]![qstq]
I would prefer to use:
Switch(acb = qstq,1, acb 0,2, acb 0,3)
So I would expect tthe result to be 2 and I have no idea how
you could get 3 unless the data values are not what you said
they are.

--
Marsh
MVP [MS Access]
 




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