In Access 2003 I am creating an Inventory Database from scratch. There are two tables (tblProductInfo rmation and tblSubProducts) that I am trying to use in a queary to determine the number of Items in Stock. The SubProducts table is linked to the Product Information table by Item # (and the information is added and viewed as a form Product Information with a Sub Form Sub Products)
I have a form (frmInventoryLo cation) where a location is selected for the Queary, the queary also has criteria to return all locations if no location is choosen.
There is a calculation field in the queary that I am using to calculate the number in stock by subtracting the # Sold from the # recieved (both fields in the SubProducts table). This calculation works fine. However, I want to limit my list to those enteries that have inventory in stock (AKA In Stock > 0) I have tried adding the >0 criteria to the calculated field but the queary still returns all results, even those with no stock.
I have managed to get around this by creating a second queary (QryInventoryLo cation) that has all the fields from the first queary (QryInventory) and the Criteria of >0 for the In Stock field. This works but requires that I have two quearys to do something that I think I should be able to accomplish in one. Does anyone have any ideas to fix my first queary to 'see' the >0 criteria?
23 2917
How about pasting in the SQL for your query? Please wrap it in the code tags by selecting the text and then clicking the # button on the top of this reply window. You can also manually edit the first tag to look just like this: [code=sql]
Regards,
Scott
Scott,
Thanks for your reply to this question...belo w I have copied and pasted the SQL view of my queary and I have used the # symbol to format the code as you requested. Please let me know if you need anything else to evaluate this issue. Thanks again for your help!! - SELECT tblSubformProducts.EventLocation, tblProductInformation.VendorCode, tblProductInformation.[Item#], tblProductInformation.Description, tblProductInformation.Category, tblProductInformation.SubCategory, tblProductInformation.Discontinued, Sum(tblSubformProducts.[# Recieved]) AS [SumOf# Recieved], Sum(tblSubformProducts.[# Sold]) AS [SumOf# Sold], Sum(tblSubformProducts![# Recieved]-tblSubformProducts![# Sold]) AS [On Hand]
-
FROM tblProductInformation INNER JOIN tblSubformProducts ON (tblProductInformation.[Item#] = tblSubformProducts.[Item #]) AND (tblProductInformation.[Item#] = tblSubformProducts.[Item #]) AND (tblProductInformation.[Item#] = tblSubformProducts.[Item #])
-
GROUP BY tblSubformProducts.EventLocation, tblProductInformation.VendorCode, tblProductInformation.[Item#], tblProductInformation.Description, tblProductInformation.Category, tblProductInformation.SubCategory, tblProductInformation.Discontinued
-
HAVING (((tblSubformProducts.EventLocation)=[Forms]![FrmInventoryLocation]![Text37]) AND ((Sum([tblSubformProducts]![# Recieved]-[tblSubformProducts]![# Sold]))>0)) OR ((([Forms]![FrmInventoryLocation]![Text37]) Is Null))
-
ORDER BY tblSubformProducts.EventLocation;
Scott,
Thanks for your reply to this question...belo w I have copied and pasted the SQL view of my queary and I have used the # symbol to format the code as you requested. Please let me know if you need anything else to evaluate this issue. Thanks again for your help!! - SELECT tblSubformProducts.EventLocation, tblProductInformation.VendorCode, tblProductInformation.[Item#], tblProductInformation.Description, tblProductInformation.Category, tblProductInformation.SubCategory, tblProductInformation.Discontinued, Sum(tblSubformProducts.[# Recieved]) AS [SumOf# Recieved], Sum(tblSubformProducts.[# Sold]) AS [SumOf# Sold], Sum(tblSubformProducts![# Recieved]-tblSubformProducts![# Sold]) AS [On Hand]
-
FROM tblProductInformation INNER JOIN tblSubformProducts ON (tblProductInformation.[Item#] = tblSubformProducts.[Item #])
-
GROUP BY tblSubformProducts.EventLocation, tblProductInformation.VendorCode, tblProductInformation.[Item#], tblProductInformation.Description, tblProductInformation.Category, tblProductInformation.SubCategory, tblProductInformation.Discontinued
-
HAVING (((tblSubformProducts.EventLocation)=[Forms]![FrmInventoryLocation]![Text37]) AND ((Sum([tblSubformProducts]![# Recieved]-[tblSubformProducts]![# Sold]))>0)) OR ((([Forms]![FrmInventoryLocation]![Text37]) Is Null))
-
ORDER BY tblSubformProducts.EventLocation;
For your calculated field, place it within an IIf statement: i.e. iif([tblSubformProdu cts]![# Recieved] => [tblSubformProdu cts]![# Sold], Sum([tblSubformProdu cts]![# Recieved] - [tblSubformProdu cts]![# Sold], "")
Regards,
Scott
Scott,
I went back to my queary and inserted the text at the point I thought it should go and when I tried to save the changes I got the following error message:
Sintax error (missing operator) in queary expression '(((tblSubformP roducts.EventLo cation)=[Forms][FrmInventoryLoc ation]![text37]) AND (iif([tblSubformProdu cts]![#Recieved]=>[tblSubformProdu cts]![#Sold], SUM ([tblSubformProdu cts]![#Recieved]-[tblSubformProdu cts![#Sold], "") Or ((([Forms]!FrmInventoryLo ca'.
When I click OK it returns me to the code and the > symbol is highlighted.
I have very little knowledge of how SQL works and appreciate your continuing help with this issue.
Scott,
I went back to my queary and inserted the text at the point I thought it should go and when I tried to save the changes I got the following error message:
Sintax error (missing operator) in queary expression '(((tblSubformP roducts.EventLo cation)=[Forms][FrmInventoryLoc ation]![text37]) AND (iif([tblSubformProdu cts]![#Recieved]=>[tblSubformProdu cts]![#Sold], SUM ([tblSubformProdu cts]![#Recieved]-[tblSubformProdu cts![#Sold], "") Or ((([Forms]!FrmInventoryLo ca'.
When I click OK it returns me to the code and the > symbol is highlighted.
I have very little knowledge of how SQL works and appreciate your continuing help with this issue.
The SQL should replace the calculated field, not be used as a WHERE criteria. In other words, if you go into the query design view and look at the Fields grid, add one that looks like this: - In Stock: IIf([tblSubformProducts]![#Recieved]... etc etc.
(obviously you'll need to retype the etc etc part :-)
Regards,
Scott
OK, I am now working in the right area anyway, I have removed my previous calculation field and have replaced it with:
In Stock: IIf([tblSubformProdu cts]![#Recieved] => [tblSubformProdu cts]![#Sold], Sum([tblSubformProdu cts]![#Recieved]-[tblSubformProdu cts]![#Sold], "")
When I try to run the queary there is an error message:
The expression you entered contains invalid syntax. You may have entered a comma without a preceding value or identifier.
When I click OK the > symbol is highlighted.
I really appreciate your continued help!
My most humble apologies! I mistyped the greater-than-or-equal-to comparison operator ;-(
It is actually >=.
Regards,
Scott
Scott,
Thank you for your continued patients with me. I have made the change from => to >= in my queary and now I get a new error message.
You tried to execute a queary that does not include the specified expression 'IIf(that line of text we've been working with)Sold], "")' as part of an aggregate function.
When I click on OK there is a curser in the table field of my grid under the calculation expression. Again, I am at a loss as to how to correct this error.
On a side note, your last post commented on the greater-than-or-equal-to comparison. If this translates the same in access as I remember it translating in math than the # recieved can be the same as the # sold, and when we subtract them from each other we would get 0 in stock. I am trying to eliminate the locations with 0 in stock from the queary, so is this the function that we want?
Again, thank you for your continued help with this issue. I really appreciate your assistance.
Not a problem... If you wish to eliminate the 0 results, then you can just change the >= to > (greater than). Putting your IIf() statement inside the Sum() function in that same field should resolve the next error message (instead of having the calculation performed inside the IIf). In Stock: Sum(IIf([tblSubformProdu cts]![#Recieved] > [tblSubformProdu cts]![#Sold], [tblSubformProdu cts]![#Recieved]-[tblSubformProdu cts]![#Sold], ""))
Regards,
Scott
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: paii |
last post by:
I have a table that stores job milestone dates. The 2 milestones I am
interested in are "Ship Date" TypeID 1 and "Revised Ship Date" TypeID 18.
All jobs have TypeID 1 only some jobs have TypeID 18. I need a query that
will return the c date for TypeID 18 if it exist else the date for TypeID 1,
for all jobs.
the table structure is the following
Job
TypeID
|
by: Steve |
last post by:
Form FrmRestock's recordsource is QryFrmRestock. The TransactionDate field's
criteria is set ats:
Forms!FrmRestock!LastXDays. LastXDays on the form is a combobox where the
selections are 30, 60 and 90. The default is set at 30.
Question1: When the form opens, there are no records displayed although there
are many records that fit the criteria of 30. If I put a button on the form to
do a requery and press the button, all the records...
|
by: John young |
last post by:
I have been looking for an answer to a problem and have found this
group and hope you can assist .
I have been re doing a data base I have made for a car club I am with
and have been trying to make a query that selects from a table as
desribed below ..
I have a table (Volunteer) that has a member field (memnumber)
and a number of fields that are headed in various categories and are
yes/no formated
|
by: Tony Williams |
last post by:
I have a database that hold s figures for each quarter. I want to create a
query whereby the user can ask for the running total of the data upto the
quarter they enter into a prompt. The database stores the quarter name in
txtmonthlabel (a date field) and the quarters totals in txtdomic (a number
field) EG If the user enters March 2004 they get figures upto March 2004, if
they enter June 2004 they get total upto June 2004, in other words...
|
by: SuffrinMick |
last post by:
Hello - I'm a newbie to coding!
I'm working on an access 2000 database which has three tables:
tblContacts - A list of customer contacts.
tblOrgTypes - A list of organisational types.
tblPositions - A list of job descriptions (Contacts can hold more than
one position)
I want to use a multi-select list box (Containing alphabetical list of
positions) to run a query. HELP!
| |
by: Crimsonwingz |
last post by:
Need to calculate a sum based on a number of factors over a period of
years. I can use formula ^x for some of it, but need totals to carry
over in the sum and have only been able to do this thus far with a loop
in a form.
Basically, I have key sums
Current savings
Current Salary
Current deposit amount
|
by: Ivan Carey |
last post by:
How can a query display multiple fields with diferent condition on the same
field
example
I have a field name of reason and a field name of duration. I would like to
display 2 fileds of total duration but each have different reasion criteria.
display Total Recall based on a calculation that adds the total duration for
each record that has a criteria of RC
on the same query display Total Shift based upon a calculation that adds the
|
by: martlaco1 |
last post by:
Trying to fix a query that (I thought) had worked once upon a time, and
I keep getting a Data Type Mismatch error whenever I enter any criteria
for an expression using a Mid function. Without the criteria, the Mid
function returns the values when I run the query. So if one of the
values is a "t" (no quotes), can I not ask to isolate that record by
putting "t" as a criteria? Nope - error, error.
If I put it within the expression itself...
|
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 June, and will
return all records in that month.
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |