dbTalk Databases Forums  

New User: IIF Statement placement and Syntax Error

comp.databases.ms-access comp.databases.ms-access


Discuss New User: IIF Statement placement and Syntax Error in the comp.databases.ms-access forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
bunzmon
 
Posts: n/a

Default New User: IIF Statement placement and Syntax Error - 12-31-2007 , 05:03 PM






Hi,

I appreciate any help I can get. I have a book on this but I still
can not get it. I am getting a syntax error on my IIF statement and I
am not sure where I should put the IIF statement. Right now I have it
placed it in the report under the details section but I wasn't sure if
I needed to create a calculated field in my table instead. The
following is my 1st IIF statement placed under the "Roast Beef" header
on my report as well as table info. Once I have this IIF statement
correct I will follow suite for the IIF statement on the Turkey and
the Rolls.

Thanks for your help.

=iif([Item Code]="RB",[Customer FName] AND " " AND [Customer LName]
AND " - " AND [Quantity] AND " " AND [QTY Code]," ")

My data base is simple:

Customer FName
Customer LName
Item Code
Item Name
Item Details
Quantity
QTY Code

Data Example 1

Customer FName=Jim
Customer LName=Smith
Item Code=RB
Item Name=Roast Beef
Item Details=Sliced Thin
Quantity=6
QTY Code=lbs

Data Example 2

Customer FName=Jim
Customer LName=Smith
Item Code=RBTR
Item Name=Rolls Buttercrust
Item Details=Sliced
Quantity=3
QTY Code=dz

Data Example 3

Customer FName=Jim
Customer LName=Smith
Item Code=TG
Item Name=Turkey & Gravy
Item Details=Sliced Thick
Quantity=4
QTY Code=lbs

Data Example 4

Customer FName=Mike
Customer LName=Jones
Item Code=RB
Item Name=Roast Beef and Gravy
Item Details=Light on the gravy
Quantity=3
QTY Code=lbs

Data Example 5

Customer FName=Mike
Customer LName=Jones
Item Code=RBTR
Item Name=Rolls Marble Rye
Item Details=
Quantity=4
QTY Code=dz

Data Example 6

Customer FName=Mike
Customer LName=Jones
Item Code=TG
Item Name=Turkey & Gravy
Item Details=Sliced Thin
Quantity=5
QTY Code=lbs

Report Output Needed:

Roast Beef Turkey Rolls

Jim Smith - 6 lbs Jim Smith - 4 lbs Jim Smith - 3 dz Rolls
Buttercrust
Sliced Thin Sliced Thick Sliced

Mike Jones - 3 lbs Mike Jones - 5 lbs Mike Jones - 4 dz Rolls
Marble Rye
Light on the Gravy Sliced Thin

Reply With Quote
  #2  
Old   
Fred Zuckerman
 
Posts: n/a

Default Re: New User: IIF Statement placement and Syntax Error - 12-31-2007 , 05:52 PM







"bunzmon" <dan (AT) bunzels (DOT) com> wrote

Quote:
Hi,

I appreciate any help I can get. I have a book on this but I still
can not get it. I am getting a syntax error on my IIF statement and I
am not sure where I should put the IIF statement. Right now I have it
placed it in the report under the details section but I wasn't sure if
I needed to create a calculated field in my table instead. The
following is my 1st IIF statement placed under the "Roast Beef" header
on my report as well as table info. Once I have this IIF statement
correct I will follow suite for the IIF statement on the Turkey and
the Rolls.

Thanks for your help.

=iif([Item Code]="RB",[Customer FName] AND " " AND [Customer LName]
AND " - " AND [Quantity] AND " " AND [QTY Code]," ")

My data base is simple:

Customer FName
Customer LName
Item Code
Item Name
Item Details
Quantity
QTY Code

Data Example 1

Customer FName=Jim
Customer LName=Smith
Item Code=RB
Item Name=Roast Beef
Item Details=Sliced Thin
Quantity=6
QTY Code=lbs

Data Example 2

Customer FName=Jim
Customer LName=Smith
Item Code=RBTR
Item Name=Rolls Buttercrust
Item Details=Sliced
Quantity=3
QTY Code=dz

Data Example 3

Customer FName=Jim
Customer LName=Smith
Item Code=TG
Item Name=Turkey & Gravy
Item Details=Sliced Thick
Quantity=4
QTY Code=lbs

Data Example 4

Customer FName=Mike
Customer LName=Jones
Item Code=RB
Item Name=Roast Beef and Gravy
Item Details=Light on the gravy
Quantity=3
QTY Code=lbs

Data Example 5

Customer FName=Mike
Customer LName=Jones
Item Code=RBTR
Item Name=Rolls Marble Rye
Item Details=
Quantity=4
QTY Code=dz

Data Example 6

Customer FName=Mike
Customer LName=Jones
Item Code=TG
Item Name=Turkey & Gravy
Item Details=Sliced Thin
Quantity=5
QTY Code=lbs

Report Output Needed:

Roast Beef Turkey Rolls

Jim Smith - 6 lbs Jim Smith - 4 lbs Jim Smith - 3 dz Rolls
Buttercrust
Sliced Thin Sliced Thick Sliced

Mike Jones - 3 lbs Mike Jones - 5 lbs Mike Jones - 4 dz Rolls
Marble Rye
Light on the Gravy Sliced Thin
Try this:

=iif([Item Code]="RB",[Customer FName] & " " & [Customer LName] & " - " &
[Quantity] & " " & [QTY Code]," ")

Fred Zuckerman





Reply With Quote
  #3  
Old   
Phil Stanton
 
Posts: n/a

Default Re: New User: IIF Statement placement and Syntax Error - 01-01-2008 , 10:55 AM



I do hope I am misinterpreting your question where you refer to a table.

Your Db should have 4 tables, 1 for Customer, 1 for Item, 1 for Qty Code and
1 for the Order. I will give more info if required

Phil

"bunzmon" <dan (AT) bunzels (DOT) com> wrote

Quote:
Hi,

I appreciate any help I can get. I have a book on this but I still
can not get it. I am getting a syntax error on my IIF statement and I
am not sure where I should put the IIF statement. Right now I have it
placed it in the report under the details section but I wasn't sure if
I needed to create a calculated field in my table instead. The
following is my 1st IIF statement placed under the "Roast Beef" header
on my report as well as table info. Once I have this IIF statement
correct I will follow suite for the IIF statement on the Turkey and
the Rolls.

Thanks for your help.

=iif([Item Code]="RB",[Customer FName] AND " " AND [Customer LName]
AND " - " AND [Quantity] AND " " AND [QTY Code]," ")

My data base is simple:

Customer FName
Customer LName
Item Code
Item Name
Item Details
Quantity
QTY Code

Data Example 1

Customer FName=Jim
Customer LName=Smith
Item Code=RB
Item Name=Roast Beef
Item Details=Sliced Thin
Quantity=6
QTY Code=lbs

Data Example 2

Customer FName=Jim
Customer LName=Smith
Item Code=RBTR
Item Name=Rolls Buttercrust
Item Details=Sliced
Quantity=3
QTY Code=dz

Data Example 3

Customer FName=Jim
Customer LName=Smith
Item Code=TG
Item Name=Turkey & Gravy
Item Details=Sliced Thick
Quantity=4
QTY Code=lbs

Data Example 4

Customer FName=Mike
Customer LName=Jones
Item Code=RB
Item Name=Roast Beef and Gravy
Item Details=Light on the gravy
Quantity=3
QTY Code=lbs

Data Example 5

Customer FName=Mike
Customer LName=Jones
Item Code=RBTR
Item Name=Rolls Marble Rye
Item Details=
Quantity=4
QTY Code=dz

Data Example 6

Customer FName=Mike
Customer LName=Jones
Item Code=TG
Item Name=Turkey & Gravy
Item Details=Sliced Thin
Quantity=5
QTY Code=lbs

Report Output Needed:

Roast Beef Turkey Rolls

Jim Smith - 6 lbs Jim Smith - 4 lbs Jim Smith - 3 dz Rolls
Buttercrust
Sliced Thin Sliced Thick Sliced

Mike Jones - 3 lbs Mike Jones - 5 lbs Mike Jones - 4 dz Rolls
Marble Rye
Light on the Gravy Sliced Thin



Reply With Quote
  #4  
Old   
Steve
 
Posts: n/a

Default Re: New User: IIF Statement placement and Syntax Error - 01-01-2008 , 09:57 PM



On Jan 1, 9:03*am, bunzmon <d... (AT) bunzels (DOT) com> wrote:
Quote:
Hi,

I appreciate any help I can get. *I have a book on this but I still
can not get it. *I am getting a syntax error on my IIF statement and I
am not sure where I should put the IIF statement. *Right now I have it
placed it in the report under the details section but I wasn't sure if
I needed to create a calculated field in my table instead. *The
following is my 1st IIF statement placed under the "Roast Beef" header
on my report as well as table info. *Once I have this IIF statement
correct I will follow suite for the IIF statement on the Turkey and
the Rolls.

Thanks for your help.

=iif([Item Code]="RB",[Customer FName] AND " " AND [Customer LName]
AND " *- *" AND [Quantity] AND " " AND [QTY Code]," ")

My data base is simple:

Customer FName
Customer LName
Item Code
Item Name
Item Details
Quantity
QTY Code

Data Example 1

Customer FName=Jim
Customer LName=Smith
Item Code=RB
Item Name=Roast Beef
Item Details=Sliced Thin
Quantity=6
QTY Code=lbs

Data Example 2

Customer FName=Jim
Customer LName=Smith
Item Code=RBTR
Item Name=Rolls Buttercrust
Item Details=Sliced
Quantity=3
QTY Code=dz

Data Example 3

Customer FName=Jim
Customer LName=Smith
Item Code=TG
Item Name=Turkey & Gravy
Item Details=Sliced Thick
Quantity=4
QTY Code=lbs

Data Example 4

Customer FName=Mike
Customer LName=Jones
Item Code=RB
Item Name=Roast Beef and Gravy
Item Details=Light on the gravy
Quantity=3
QTY Code=lbs

Data Example 5

Customer FName=Mike
Customer LName=Jones
Item Code=RBTR
Item Name=Rolls Marble Rye
Item Details=
Quantity=4
QTY Code=dz

Data Example 6

Customer FName=Mike
Customer LName=Jones
Item Code=TG
Item Name=Turkey & Gravy
Item Details=Sliced Thin
Quantity=5
QTY Code=lbs

Report Output Needed:

Roast Beef * * * * * * * *Turkey * * * * * * * * *Rolls

Jim Smith - 6 lbs * * * Jim Smith - 4 lbs * *Jim Smith - 3 dz Rolls
Buttercrust
Sliced Thin * * * * * * * *Sliced Thick * * * * *Sliced

Mike Jones - 3 lbs * * Mike Jones - 5 lbs *Mike Jones - 4 dz Rolls
Marble Rye
Light on the Gravy * * Sliced Thin
Bunzmon
You are where I was a few years ago (and I am far far from being an
expert) but its probably worth getting some real basics sorted out
first:

Tables - Where you store data and you should have tables that do not
duplicate data eg store the names and address in one table and the
items you sell in another and the actual sales in another. You can
get very fussy with this non duplication (its called normalisation and
it is smart to do so but probably better addressed later (no pun
intended). Biggest mistake I used to (and sometimes still do) is to
put too much information in one table. Much better to have many
smaller tables which are joined (linked) by a particular field. Eg
the Names table may have a field for Country. Instead of storing each
country name in there, you would store a link to another table with
all the countries in it. Both much more efficient and if a Country
name changes you only have to change the name once in the Country
table

Queries - Where you select or manipulate data from Tables or other
queries. Eg you might only want certain people from your name and
address Table. You would create a query based on the Names table and
use criteria to limit the list to certain people. (eg name = Fred).
You also use queries to do calculations eg the Items table has the
value of a sandwich and your sales table has the quantity sold. A
query would be used to multiply the quantity from the sales table by
the value in the item table to get a total sales value

Reports- Used to show information in a friendly (?) form. Can be
based on information from Tables or Queries or a combination.

Back to your original question: eg if you wanted Roast Beef sales for
Fred Nurks only, you would create a query which connected (joined)
your Names table, your sales table and your item table
The iif statement would be used in this query to show a new field
that can be used to select just the items that met your if statement
criteria.

Apologies. That turned out to be surpisingly difficult to simplify
without being patronising or simplify so much I steered you in the
wrong directions. Bottom line - go back to basics and get very clear
on the difference between Tables and Queries or you could waste a lot
of time going the wrong way
Steve


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.