Solved

Access 2000 Query to use the larger of two numbers

Posted on 2006-06-29
2
215 Views
Last Modified: 2008-02-01
I need to use the larger of two numbers in a calculation in my query.

Pseudo code would be like:

If Inventory_Qty > Order_Qty then
  ' Inventory_Qty - Components_needed = Surplus (below is the SQL)
  ([Inventory].[Quantity]-([Forms]![BOM_Queries]![txtBuilds]*[Qty per Asm])) AS Surplus)  
else
  'Order_Qty - Components_needed = Surplus
  ([Orders Subtable].[Quantity]-([Forms]![BOM_Queries]![txtBuilds]*[Qty per Asm])) AS Surplus)
end if

It has to be SQL as it is part of a Access 2000 Query.
0
Comment
Question by:schmir1
2 Comments
 
LVL 35

Accepted Solution

by:
Raynard7 earned 500 total points
Comment Utility
Have you tried using an IIF statement;

this is where the test is in the first arguement, the result for true is in the second and the result for false is in the third,

ie Surplus: IIF(Inventory_Qty > Order_Qty, ([Inventory].[Quantity]-([Forms]![BOM_Queries]![txtBuilds]*[Qty per Asm]))),  ([Orders Subtable].[Quantity]-([Forms]![BOM_Queries]![txtBuilds]*[Qty per Asm]))))
0
 

Author Comment

by:schmir1
Comment Utility
Thanks works great.
0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Suggested Solutions

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

771 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now