Results 1 to 14 of 14
  1. #1
    lalaland is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    8

    HELP: Query Problem using IF statement

    I have to create a query with this:

    Each painting costs $350 to ship and $500 extra if the museum purchases insurance to cover shipping. Use an IF statement to add the insurance cost.



    How do I add a Total Cost Column for the query table and the calculated amount for the paintings?? Pls help

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    How do you know the museum purchases insurance? Is there a field in table that indicates this? Is it a Yes/No field? Create field in query with an expression:

    InsuranceCost: IIf([Insurance] = True, 500, 0)
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    lalaland is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    8
    Quote Originally Posted by June7 View Post
    How do you know the museum purchases insurance? Is there a field in table that indicates this? Is it a Yes/No field? Create field in query with an expression:

    InsuranceCost: IIf([Insurance] = True, 500, 0)
    Yes. I have a Shipment Log table that indicates if the shipment is insured or not with a field: Insurance and yes it's a Yes/No field..

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    Did the suggestion work?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    lalaland is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    8
    Quote Originally Posted by June7 View Post
    Did the suggestion work?
    it did..i had to add both numbers for those who are insured (550+350) BUT it doesnt calculate the total for each shipment. For example, Shipment 1 isnt compressed to just one total, instead, there are a bunch of shipment 1s. I want to calculate the total shipment cost of each ID by not being redundant.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    Then do an aggregate (Totals) query.

    Or maybe better, build a report and use Grouping & Sorting with aggregate calcs in footers. Report will allow display of detail records as well as summary calculations.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    lalaland is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    8
    Quote Originally Posted by June7 View Post
    Then do an aggregate (Totals) query.

    Or maybe better, build a report and use Grouping & Sorting with aggregate calcs in footers. Report will allow display of detail records as well as summary calculations.
    Ok thanks!

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    On second thought, not sure that is correct recommendation.

    Why is there a bunch of shipment 1s?

    Not understanding your data structure. If you want to provide db for analysis, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    lalaland is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    8
    Quote Originally Posted by June7 View Post
    On second thought, not sure that is correct recommendation.

    Why is there a bunch of shipment 1s?

    Not understanding your data structure. If you want to provide db for analysis, follow instructions at bottom of my post.
    Movable Art Database (2).zip

    Kk I attached it.

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    There is a bunch of shipment 1s because the Shipping List by ID query does not have a join clause. This causes every record in each table to associate with every record of the other table.

    Your tables are not properly related.

    The primary key for Paintings is PaintingID, however you are saving the OwnerID in Shipping Log. The painting is shipped, not the owner. Why aren't you saving the PaintingID pk as fk in Shipping Log?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    lalaland is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    8
    Quote Originally Posted by June7 View Post
    There is a bunch of shipment 1s because the Shipping List by ID query does not have a join clause. This causes every record in each table to associate with every record of the other table.

    Your tables are not properly related.

    The primary key for Paintings is PaintingID, however you are saving the OwnerID in Shipping Log. The painting is shipped, not the owner. Why aren't you saving the PaintingID pk as fk in Shipping Log?
    Our instructor specified to add owner id in the shipping log since the instructor says that owner id is the museum? I didn't really get that part. I'm soo confused..

  12. #12
    lalaland is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    8
    https://www.cengagebrain.com.au/cont...1285213781.pdf I found a link online where our instructor got this project.(Moving Art Database - just scroll down the pdf) However, our deliverables are a bit different. Ours is ER diagram, Tables created in Access, Form and Subform: Shipping, Query 1: Paintings by Picasso and Warhol, Query 2:Pre-1900 and NY Paintings, Query 3: Shipping List by ID, Query 4: Shipping Costs, Reprt 1:Shipping Costs and Report 2: ERD. The Background is the same as the one given to us.

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    Each owner can have multiple paintings. Which painting was shipped? You may include the ownerID (does this mean painting has a new owner and Paintings table should be edited to reflect?) but I expect paintingID is mandatory in Shipping Log. Then link the tables in the query joining on the common paintingID fields.

    This assumes each shipment is for a single painting. If not, that is another issue and will need another table.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  14. #14
    lalaland is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    8
    Quote Originally Posted by June7 View Post
    Each owner can have multiple paintings. Which painting was shipped? You may include the ownerID (does this mean painting has a new owner and Paintings table should be edited to reflect?) but I expect paintingID is mandatory in Shipping Log. Then link the tables in the query joining on the common paintingID fields.

    This assumes each shipment is for a single painting. If not, that is another issue and will need another table.
    I got it!! Thanks soo much!!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Syntax problem with IIF statement
    By supracharger in forum Reports
    Replies: 12
    Last Post: 06-03-2012, 05:10 PM
  2. IF/THEN statement problem
    By sfgiantsdude in forum Access
    Replies: 5
    Last Post: 01-06-2012, 03:50 PM
  3. problem with IF THEN statement in access 2003 query
    By sfgiantsdude in forum Access
    Replies: 4
    Last Post: 01-05-2012, 04:23 PM
  4. Problem with a IIF statement
    By Genzo in forum Access
    Replies: 10
    Last Post: 08-31-2011, 10:46 AM
  5. Problem With IF Statement
    By MuskokaMad in forum Programming
    Replies: 0
    Last Post: 03-14-2010, 05:26 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums