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  

Using IIF on Exclusive Fields



 
 
Thread Tools Display Modes
  #1  
Old June 23rd, 2008, 09:44 PM posted to microsoft.public.access.queries
Roger Denison
external usenet poster
 
Posts: 6
Default Using IIF on Exclusive Fields

I'm trying to develop a query on a table that rather than have one column for
the day ("Mon", "Tues", etc or "2", "3", etc), it has 7 columns of type
tinyInt, one for each day. A Monday item would have a 1 in the M column. A
Saturday item would have a 1 in the S column. All other columns would have 0.

I would like to have a list on a form that if the user selects a day, the
query will filter for just that day. But I keep getting empty rows.

For simplicity, here is the SQL for a "Monday" example: (if I can get this
then I can add multiple criteria for the other days)
SELECT dbo_Garment.BC, dbo_Garment.M, dbo_Garment.T, dbo_Garment.W,
dbo_Garment.R, dbo_Garment.F, dbo_Garment.S, dbo_Garment.U
FROM dbo_Garment
WHERE (((dbo_Garment.M)=IIf("Forms![Shipping
Report]![lstDay]"="Monday",1,0)) AND ((dbo_Garment.T)=0) AND
((dbo_Garment.W)=0) AND ((dbo_Garment.R)=0) AND ((dbo_Garment.F)=0) AND
((dbo_Garment.S)=0) AND ((dbo_Garment.U)=0));

where M, T, W, R, F, S, and U are the days of the week.

If I run the query without the IIF statement (force M's criteria to 1), then
I get the desireed results, but if I use the IIF statement then I get nothing.
  #2  
Old June 23rd, 2008, 10:37 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Using IIF on Exclusive Fields

I do not follow but try changing your syntax --
SELECT dbo_Garment.BC, dbo_Garment.M, dbo_Garment.T, dbo_Garment.W,
dbo_Garment.R, dbo_Garment.F, dbo_Garment.S, dbo_Garment.U
FROM dbo_Garment
WHERE (((dbo_Garment.M)=IIf([Forms]![Shipping
Report]![lstDay]="Monday",1,0)) AND ((dbo_Garment.T)=0) AND
((dbo_Garment.W)=0) AND ((dbo_Garment.R)=0) AND ((dbo_Garment.F)=0) AND
((dbo_Garment.S)=0) AND ((dbo_Garment.U)=0));

--
KARL DEWEY
Build a little - Test a little


"Roger Denison" wrote:

I'm trying to develop a query on a table that rather than have one column for
the day ("Mon", "Tues", etc or "2", "3", etc), it has 7 columns of type
tinyInt, one for each day. A Monday item would have a 1 in the M column. A
Saturday item would have a 1 in the S column. All other columns would have 0.

I would like to have a list on a form that if the user selects a day, the
query will filter for just that day. But I keep getting empty rows.

For simplicity, here is the SQL for a "Monday" example: (if I can get this
then I can add multiple criteria for the other days)
SELECT dbo_Garment.BC, dbo_Garment.M, dbo_Garment.T, dbo_Garment.W,
dbo_Garment.R, dbo_Garment.F, dbo_Garment.S, dbo_Garment.U
FROM dbo_Garment
WHERE (((dbo_Garment.M)=IIf("Forms![Shipping
Report]![lstDay]"="Monday",1,0)) AND ((dbo_Garment.T)=0) AND
((dbo_Garment.W)=0) AND ((dbo_Garment.R)=0) AND ((dbo_Garment.F)=0) AND
((dbo_Garment.S)=0) AND ((dbo_Garment.U)=0));

where M, T, W, R, F, S, and U are the days of the week.

If I run the query without the IIF statement (force M's criteria to 1), then
I get the desireed results, but if I use the IIF statement then I get nothing.

  #3  
Old June 24th, 2008, 07:50 PM posted to microsoft.public.access.queries
Roger Denison
external usenet poster
 
Posts: 6
Default Using IIF on Exclusive Fields

Ahhh, yes! The ol' Forms-in-square-brackets trick! Thanks.

"KARL DEWEY" wrote:

I do not follow but try changing your syntax --
SELECT dbo_Garment.BC, dbo_Garment.M, dbo_Garment.T, dbo_Garment.W,
dbo_Garment.R, dbo_Garment.F, dbo_Garment.S, dbo_Garment.U
FROM dbo_Garment
WHERE (((dbo_Garment.M)=IIf([Forms]![Shipping
Report]![lstDay]="Monday",1,0)) AND ((dbo_Garment.T)=0) AND
((dbo_Garment.W)=0) AND ((dbo_Garment.R)=0) AND ((dbo_Garment.F)=0) AND
((dbo_Garment.S)=0) AND ((dbo_Garment.U)=0));

--
KARL DEWEY
Build a little - Test a little


"Roger Denison" wrote:

I'm trying to develop a query on a table that rather than have one column for
the day ("Mon", "Tues", etc or "2", "3", etc), it has 7 columns of type
tinyInt, one for each day. A Monday item would have a 1 in the M column. A
Saturday item would have a 1 in the S column. All other columns would have 0.

I would like to have a list on a form that if the user selects a day, the
query will filter for just that day. But I keep getting empty rows.

For simplicity, here is the SQL for a "Monday" example: (if I can get this
then I can add multiple criteria for the other days)
SELECT dbo_Garment.BC, dbo_Garment.M, dbo_Garment.T, dbo_Garment.W,
dbo_Garment.R, dbo_Garment.F, dbo_Garment.S, dbo_Garment.U
FROM dbo_Garment
WHERE (((dbo_Garment.M)=IIf("Forms![Shipping
Report]![lstDay]"="Monday",1,0)) AND ((dbo_Garment.T)=0) AND
((dbo_Garment.W)=0) AND ((dbo_Garment.R)=0) AND ((dbo_Garment.F)=0) AND
((dbo_Garment.S)=0) AND ((dbo_Garment.U)=0));

where M, T, W, R, F, S, and U are the days of the week.

If I run the query without the IIF statement (force M's criteria to 1), then
I get the desireed results, but if I use the IIF statement then I get nothing.

 




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 06:21 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.