473,398 Members | 2,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Query Question

I am working with the Inventory Dbase and I have a “Reorder Level” field which the quantity varies. I also have a query field Qty On Hand

[PHP]Qty On Hand: Sum([Material Inventory Tran]![Qty Received]-[Material Inventory Tran]![Qty Issued])[/PHP]

I’m trying to make a query to show all "Qty On Hand" that is less than the "Reorder Level". How do I make that Statement.

Thanks
John
Aug 6 '08 #1
9 1552
janders468
112 Expert 100+
Is there only one record in your reorder table? If so then select from your on hand query where Quantity On Hand < tblReorder.ReorderLevel. For instance if you call your on hand query OnHand_qry and your Reorder table Reorder_tbl then the query would be:
Expand|Select|Wrap|Line Numbers
  1. Select OnHand_qry.QuantityOnHand FROM OnHand_qry, Reorder_tbl
  2. WHERE OnHand_qry.QuantityOnHand < Reorder_tbl.ReorderLevel
  3.  
Aug 6 '08 #2
NeoPa
32,556 Expert Mod 16PB
Is the [Reorder Level] field found in the same recordset that the query is run from? You should really include the relevant information in the question John.
Aug 6 '08 #3
Is the [Reorder Level] field found in the same recordset that the query is run from? You should really include the relevant information in the question John.
Yes- The "Reorder Level" field is in the same recordset that the query is run from. I'm having a hard time since that the "Qty On Hand" is an expression otherwise I can do some thing like "Qty On Hand<= Reorder Level" and it just doesn't work.

I'll try the first suggestion. Thank you for the reply!
Aug 7 '08 #4
NeoPa
32,556 Expert Mod 16PB
No. It won't.

This is because the WHERE and HAVING clauses are processed before the SELECT clause.

You probably need something like :
Expand|Select|Wrap|Line Numbers
  1. ...
  2. FROM [Material Inventory Tran]
  3. GROUP BY ???
  4. HAVING (Sum([Qty Received]-[Qty Issued])<[Reorder Level])
Aug 7 '08 #5
NeoPa
32,556 Expert Mod 16PB
If that's a bit confusing for you, pop your existing SQL code in here and we'll see what we can do for you.
Aug 7 '08 #6
Here's the existing SQL Code:
Thanks again!

[PHP]SELECT [Material Inventory].[Part Number], [Material Inventory].[Alternate Part Number], [Material Inventory].Description, [Material Inventory].Rev, [Material Inventory].[Unit of Measure], [Material Inventory].Location, Sum([Material Inventory Tran].[Qty Received]) AS [SumOfQty Received], Sum([Material Inventory Tran].[Qty Issued]) AS [SumOfQty Issued], Sum([Material Inventory Tran]![Qty Received]-[Material Inventory Tran]![Qty Issued]) AS [Qty On Hand], [Material Inventory].[Reorder Level]
FROM [Material Inventory] RIGHT JOIN [Material Inventory Tran] ON [Material Inventory].MIID = [Material Inventory Tran].MIID
GROUP BY [Material Inventory].[Part Number], [Material Inventory].[Alternate Part Number], [Material Inventory].Description, [Material Inventory].Rev, [Material Inventory].[Unit of Measure], [Material Inventory].Location, [Material Inventory].[Reorder Level]
HAVING (((Sum([Material Inventory Tran]![Qty Received]-[Material Inventory Tran]![Qty Issued]))>0));[/PHP]
Aug 7 '08 #7
NeoPa
32,556 Expert Mod 16PB
Try this - and notice how it's laid out to be legible and understandable. It really makes life so much easier for you.
Expand|Select|Wrap|Line Numbers
  1. SELECT MI.[Part Number],
  2.        MI.[Alternate Part Number],
  3.        MI.Description,
  4.        MI.Rev,
  5.        MI.[Unit of Measure],
  6.        MI.Location,
  7.        Sum(MIT.[Qty Received]) AS [SumOfQty Received],
  8.        Sum(MIT.[Qty Issued]) AS [SumOfQty Issued],
  9.        Sum(MIT.[Qty Received]-MIT.[Qty Issued]) AS [Qty On Hand],
  10.        MI.[Reorder Level]
  11.  
  12. FROM [Material Inventory] AS MI RIGHT JOIN [Material Inventory Tran] AS MIT
  13.   ON MI.MIID=MIT.MIID
  14.  
  15. GROUP BY MI.[Part Number],
  16.          MI.[Alternate Part Number],
  17.          MI.Description,
  18.          MI.Rev,
  19.          MI.[Unit of Measure],
  20.          MI.Location,
  21.          MI.[Reorder Level]
  22.  
  23. HAVING (Sum(MIT.[Qty Received]-MIT.[Qty Issued])>=MI.[Reorder Level])
Aug 7 '08 #8
THANK YOU VERY MUCH!!!! I'll try it.. Sorry for slow response- just got back from work!
John
Aug 11 '08 #9
NeoPa
32,556 Expert Mod 16PB
You're welcome - and no worries about any delay. We don't expect anyone to be online all the time.
Aug 11 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: majsen | last post by:
Hi, I have problem running this query. It will time out for me... My database are small just about 200 members. I have a site for swaping appartments (rental). my query should look for match in...
8
by: Együd Csaba | last post by:
Hi All, how can I improve the query performance in the following situation: I have a big (4.5+ million rows) table. One query takes approx. 9 sec to finish resulting ~10000 rows. But if I run...
3
by: John Ortt | last post by:
> I have a table of dates in ascending order but with varying intervals. I > would like to create a query to pull out the date (in field 1) and then pull > the date from the subsequent record...
3
by: Ekqvist Marko | last post by:
Hi, I have one Access database table including questions and answers. Now I need to give answer id automatically to questionID column. But I don't know how it is best (fastest) to do? table...
7
by: serge | last post by:
How can I run a single SP by asking multiple sales question either by using the logical operator AND for all the questions; or using the logical operator OR for all the questions. So it's always...
6
by: jjturon | last post by:
Can anyone help me?? I am trying to pass a Select Query variable to a table using Dlookup and return the value to same select query but to another field. Ex. SalesManID ...
2
by: mmitchell_houston | last post by:
I'm working on a .NET project and I need a single query to return a result set from three related tables in Access 2003, and I'm having trouble getting the results I want. The details: ...
22
by: Stan | last post by:
I am working with Access 2003 on a computer running XP. I am new at using Access. I have a Db with a date field stored as mm/dd/yyyy. I need a Query that will prompt for the month, ie. 6 for...
3
by: Richard Hollenbeck | last post by:
I am very sorry about the (almost) re-post, but you will see that my first question wasn't very clear; I have another question I posted this morning called, "in DAO: Run time error 3061 Too few...
16
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.