Solved

MS Access query: Return a value based on the value in another field

Posted on 2012-04-10
4
383 Views
Last Modified: 2012-04-11
IFTHENExample-2012-04-10.accdbI am trying to write a query (see qryGMUtility) that returns the commission that we pay on each product sales record.  The commissions we pay are stored in a table called “UtilityPayout”.  
Commissions are only paid when the orders are accepted by the utility, that is, the UtilityStatus="Accepted by Utility".  Therefore, the value in the field “Payout” should be $0 if the UtilityStatus=”Rejected by Utility”, otherwise, the payout value should be  taken from the UtilityPayout table.
Here’s one of the things that I tried without success: IIf([qrytblSalesToo].[UtilityStatus]="Rejected*",0,[Payout])
Attached is a small extract of the db with the query.
Thanks for your help and any pointers that you can give me to help me learn.
BTW, does anyone know why "TCP/IP" is showing up as a topic under "Select Topics" where I submit this question?  I can't get rid of it.
0
Comment
Question by:thutchinson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 22

Accepted Solution

by:
Flyster earned 500 total points
ID: 37831152
See qryGMUtility of attached file, Commission Field. If you want the query to return only paid commissions, put ">0" (without quotes) in the criteria section.

Flyster
IFTHENExample-2012-04-10.accdb
0
 

Author Comment

by:thutchinson
ID: 37832446
I want all the records returned (accepted and rejected).  I want the value in PAYOUT to be -0- when the order is rejected.  I want the Payout value if the order is accepted.
0
 

Author Comment

by:thutchinson
ID: 37833113
OK, I'm able to get the Gross Margin on all sales if I make a couple of changes to the code you suggested. it works now like this:

CommissionPayout: IIf([UtilityStatus]="Rejected by Utility",0,[Payout])
Margin: [qrytblSalesToo].[Payment]-[CommissionPayout]


Thanks for your help, Flyster.  I really appreciate it!
0
 
LVL 22

Expert Comment

by:Flyster
ID: 37833805
Thank you. I'm glad I was able to assist!
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question